@pega/react-sdk-components 8.23.11 → 23.1.10

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 (499) hide show
  1. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.d.ts +7 -10
  2. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.d.ts.map +1 -1
  3. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.js +0 -7
  4. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.js.map +1 -1
  5. package/lib/components/designSystemExtension/Banner/Banner.d.ts +15 -1
  6. package/lib/components/designSystemExtension/Banner/Banner.d.ts.map +1 -1
  7. package/lib/components/designSystemExtension/Banner/Banner.js.map +1 -1
  8. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.d.ts +6 -9
  9. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.d.ts.map +1 -1
  10. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.js +3 -7
  11. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.js.map +1 -1
  12. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.d.ts +4 -10
  13. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.d.ts.map +1 -1
  14. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.js +1 -8
  15. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.js.map +1 -1
  16. package/lib/components/designSystemExtension/FieldGroup/FieldGroup.d.ts +6 -2
  17. package/lib/components/designSystemExtension/FieldGroup/FieldGroup.d.ts.map +1 -1
  18. package/lib/components/designSystemExtension/FieldGroup/FieldGroup.js +3 -3
  19. package/lib/components/designSystemExtension/FieldGroup/FieldGroup.js.map +1 -1
  20. package/lib/components/designSystemExtension/FieldGroupList/FieldGroupList.d.ts +7 -2
  21. package/lib/components/designSystemExtension/FieldGroupList/FieldGroupList.d.ts.map +1 -1
  22. package/lib/components/designSystemExtension/FieldGroupList/FieldGroupList.js +3 -3
  23. package/lib/components/designSystemExtension/FieldGroupList/FieldGroupList.js.map +1 -1
  24. package/lib/components/designSystemExtension/FieldValueList/FieldValueList.d.ts +7 -2
  25. package/lib/components/designSystemExtension/FieldValueList/FieldValueList.d.ts.map +1 -1
  26. package/lib/components/designSystemExtension/FieldValueList/FieldValueList.js +3 -3
  27. package/lib/components/designSystemExtension/FieldValueList/FieldValueList.js.map +1 -1
  28. package/lib/components/designSystemExtension/Operator/Operator.d.ts +17 -7
  29. package/lib/components/designSystemExtension/Operator/Operator.d.ts.map +1 -1
  30. package/lib/components/designSystemExtension/Operator/Operator.js +1 -6
  31. package/lib/components/designSystemExtension/Operator/Operator.js.map +1 -1
  32. package/lib/components/designSystemExtension/Pulse/Pulse.d.ts +5 -1
  33. package/lib/components/designSystemExtension/Pulse/Pulse.d.ts.map +1 -1
  34. package/lib/components/designSystemExtension/Pulse/Pulse.js +3 -6
  35. package/lib/components/designSystemExtension/Pulse/Pulse.js.map +1 -1
  36. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.d.ts +19 -0
  37. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.d.ts.map +1 -0
  38. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.js +77 -0
  39. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.js.map +1 -0
  40. package/lib/components/designSystemExtension/RichTextEditor/index.d.ts +2 -0
  41. package/lib/components/designSystemExtension/RichTextEditor/index.d.ts.map +1 -0
  42. package/lib/components/designSystemExtension/RichTextEditor/index.js +2 -0
  43. package/lib/components/designSystemExtension/RichTextEditor/index.js.map +1 -0
  44. package/lib/components/designSystemExtension/WssQuickCreate/WssQuickCreate.d.ts +6 -1
  45. package/lib/components/designSystemExtension/WssQuickCreate/WssQuickCreate.d.ts.map +1 -1
  46. package/lib/components/designSystemExtension/WssQuickCreate/WssQuickCreate.js.map +1 -1
  47. package/lib/components/field/AutoComplete/AutoComplete.d.ts +15 -1
  48. package/lib/components/field/AutoComplete/AutoComplete.d.ts.map +1 -1
  49. package/lib/components/field/AutoComplete/AutoComplete.js +18 -16
  50. package/lib/components/field/AutoComplete/AutoComplete.js.map +1 -1
  51. package/lib/components/field/CancelAlert/CancelAlert.d.ts +7 -2
  52. package/lib/components/field/CancelAlert/CancelAlert.d.ts.map +1 -1
  53. package/lib/components/field/CancelAlert/CancelAlert.js +3 -3
  54. package/lib/components/field/CancelAlert/CancelAlert.js.map +1 -1
  55. package/lib/components/field/Checkbox/Checkbox.d.ts.map +1 -1
  56. package/lib/components/field/Checkbox/Checkbox.js +35 -7
  57. package/lib/components/field/Checkbox/Checkbox.js.map +1 -1
  58. package/lib/components/field/Currency/Currency.d.ts +6 -1
  59. package/lib/components/field/Currency/Currency.d.ts.map +1 -1
  60. package/lib/components/field/Currency/Currency.js +12 -12
  61. package/lib/components/field/Currency/Currency.js.map +1 -1
  62. package/lib/components/field/Currency/currency-utils.d.ts.map +1 -1
  63. package/lib/components/field/Currency/currency-utils.js +1 -1
  64. package/lib/components/field/Currency/currency-utils.js.map +1 -1
  65. package/lib/components/field/Date/Date.d.ts +5 -1
  66. package/lib/components/field/Date/Date.d.ts.map +1 -1
  67. package/lib/components/field/Date/Date.js +9 -7
  68. package/lib/components/field/Date/Date.js.map +1 -1
  69. package/lib/components/field/DateTime/DateTime.d.ts +5 -1
  70. package/lib/components/field/DateTime/DateTime.d.ts.map +1 -1
  71. package/lib/components/field/DateTime/DateTime.js +15 -9
  72. package/lib/components/field/DateTime/DateTime.js.map +1 -1
  73. package/lib/components/field/Decimal/Decimal.d.ts +8 -1
  74. package/lib/components/field/Decimal/Decimal.d.ts.map +1 -1
  75. package/lib/components/field/Decimal/Decimal.js +11 -10
  76. package/lib/components/field/Decimal/Decimal.js.map +1 -1
  77. package/lib/components/field/Dropdown/Dropdown.d.ts.map +1 -1
  78. package/lib/components/field/Dropdown/Dropdown.js +26 -12
  79. package/lib/components/field/Dropdown/Dropdown.js.map +1 -1
  80. package/lib/components/field/Email/Email.d.ts +5 -1
  81. package/lib/components/field/Email/Email.d.ts.map +1 -1
  82. package/lib/components/field/Email/Email.js +7 -5
  83. package/lib/components/field/Email/Email.js.map +1 -1
  84. package/lib/components/field/Integer/Integer.d.ts +5 -1
  85. package/lib/components/field/Integer/Integer.d.ts.map +1 -1
  86. package/lib/components/field/Integer/Integer.js +6 -4
  87. package/lib/components/field/Integer/Integer.js.map +1 -1
  88. package/lib/components/field/Percentage/Percentage.d.ts +5 -1
  89. package/lib/components/field/Percentage/Percentage.d.ts.map +1 -1
  90. package/lib/components/field/Percentage/Percentage.js +6 -4
  91. package/lib/components/field/Percentage/Percentage.js.map +1 -1
  92. package/lib/components/field/Phone/Phone.d.ts +5 -1
  93. package/lib/components/field/Phone/Phone.d.ts.map +1 -1
  94. package/lib/components/field/Phone/Phone.js +8 -6
  95. package/lib/components/field/Phone/Phone.js.map +1 -1
  96. package/lib/components/field/RadioButtons/RadioButtons.d.ts.map +1 -1
  97. package/lib/components/field/RadioButtons/RadioButtons.js +21 -14
  98. package/lib/components/field/RadioButtons/RadioButtons.js.map +1 -1
  99. package/lib/components/field/RichText/RichText.d.ts +7 -0
  100. package/lib/components/field/RichText/RichText.d.ts.map +1 -0
  101. package/lib/components/field/RichText/RichText.js +53 -0
  102. package/lib/components/field/RichText/RichText.js.map +1 -0
  103. package/lib/components/field/RichText/index.d.ts +2 -0
  104. package/lib/components/field/RichText/index.d.ts.map +1 -0
  105. package/lib/components/field/RichText/index.js +2 -0
  106. package/lib/components/field/RichText/index.js.map +1 -0
  107. package/lib/components/field/ScalarList/ScalarList.d.ts +13 -0
  108. package/lib/components/field/ScalarList/ScalarList.d.ts.map +1 -0
  109. package/lib/components/field/ScalarList/ScalarList.js +34 -0
  110. package/lib/components/field/ScalarList/ScalarList.js.map +1 -0
  111. package/lib/components/field/ScalarList/index.d.ts +2 -0
  112. package/lib/components/field/ScalarList/index.d.ts.map +1 -0
  113. package/lib/components/field/ScalarList/index.js +2 -0
  114. package/lib/components/field/ScalarList/index.js.map +1 -0
  115. package/lib/components/field/SemanticLink/SemanticLink.d.ts +5 -9
  116. package/lib/components/field/SemanticLink/SemanticLink.d.ts.map +1 -1
  117. package/lib/components/field/SemanticLink/SemanticLink.js +10 -14
  118. package/lib/components/field/SemanticLink/SemanticLink.js.map +1 -1
  119. package/lib/components/field/TextArea/TextArea.d.ts +6 -1
  120. package/lib/components/field/TextArea/TextArea.d.ts.map +1 -1
  121. package/lib/components/field/TextArea/TextArea.js +5 -3
  122. package/lib/components/field/TextArea/TextArea.js.map +1 -1
  123. package/lib/components/field/TextContent/TextContent.d.ts +7 -1
  124. package/lib/components/field/TextContent/TextContent.d.ts.map +1 -1
  125. package/lib/components/field/TextContent/TextContent.js.map +1 -1
  126. package/lib/components/field/TextInput/TextInput.d.ts +6 -1
  127. package/lib/components/field/TextInput/TextInput.d.ts.map +1 -1
  128. package/lib/components/field/TextInput/TextInput.js +7 -5
  129. package/lib/components/field/TextInput/TextInput.js.map +1 -1
  130. package/lib/components/field/Time/Time.d.ts +5 -1
  131. package/lib/components/field/Time/Time.d.ts.map +1 -1
  132. package/lib/components/field/Time/Time.js +10 -8
  133. package/lib/components/field/Time/Time.js.map +1 -1
  134. package/lib/components/field/URL/URL.d.ts +5 -1
  135. package/lib/components/field/URL/URL.d.ts.map +1 -1
  136. package/lib/components/field/URL/URL.js +6 -4
  137. package/lib/components/field/URL/URL.js.map +1 -1
  138. package/lib/components/field/UserReference/UserReference.d.ts +19 -40
  139. package/lib/components/field/UserReference/UserReference.d.ts.map +1 -1
  140. package/lib/components/field/UserReference/UserReference.js +16 -45
  141. package/lib/components/field/UserReference/UserReference.js.map +1 -1
  142. package/lib/components/helpers/attachmentHelpers.d.ts +3 -3
  143. package/lib/components/helpers/attachmentHelpers.d.ts.map +1 -1
  144. package/lib/components/helpers/attachmentHelpers.js.map +1 -1
  145. package/lib/components/helpers/auth.d.ts +8 -6
  146. package/lib/components/helpers/auth.d.ts.map +1 -1
  147. package/lib/components/helpers/auth.js +642 -327
  148. package/lib/components/helpers/auth.js.map +1 -1
  149. package/lib/components/helpers/authManager.d.ts +20 -17
  150. package/lib/components/helpers/authManager.d.ts.map +1 -1
  151. package/lib/components/helpers/authManager.js +711 -439
  152. package/lib/components/helpers/authManager.js.map +1 -1
  153. package/lib/components/helpers/case-utils.d.ts.map +1 -1
  154. package/lib/components/helpers/case-utils.js +5 -4
  155. package/lib/components/helpers/case-utils.js.map +1 -1
  156. package/lib/components/helpers/common-utils.d.ts +1 -1
  157. package/lib/components/helpers/common-utils.js.map +1 -1
  158. package/lib/components/helpers/config_access.d.ts.map +1 -1
  159. package/lib/components/helpers/config_access.js +0 -63
  160. package/lib/components/helpers/config_access.js.map +1 -1
  161. package/lib/components/helpers/date-format-utils.d.ts +1 -6
  162. package/lib/components/helpers/date-format-utils.d.ts.map +1 -1
  163. package/lib/components/helpers/date-format-utils.js.map +1 -1
  164. package/lib/components/helpers/event-utils.d.ts +1 -1
  165. package/lib/components/helpers/event-utils.d.ts.map +1 -1
  166. package/lib/components/helpers/event-utils.js.map +1 -1
  167. package/lib/components/helpers/field-group-utils.d.ts.map +1 -1
  168. package/lib/components/helpers/field-group-utils.js +4 -8
  169. package/lib/components/helpers/field-group-utils.js.map +1 -1
  170. package/lib/components/helpers/formatters/Currency.d.ts +6 -6
  171. package/lib/components/helpers/formatters/Currency.js +2 -2
  172. package/lib/components/helpers/formatters/Currency.js.map +1 -1
  173. package/lib/components/helpers/formatters/CurrencyMap.d.ts +69 -320
  174. package/lib/components/helpers/formatters/CurrencyMap.d.ts.map +1 -1
  175. package/lib/components/helpers/formatters/CurrencyMap.js.map +1 -1
  176. package/lib/components/helpers/formatters/Date.d.ts +4 -4
  177. package/lib/components/helpers/formatters/Date.js.map +1 -1
  178. package/lib/components/helpers/formatters/common.d.ts +1 -1
  179. package/lib/components/helpers/formatters/common.d.ts.map +1 -1
  180. package/lib/components/helpers/formatters/common.js.map +1 -1
  181. package/lib/components/helpers/formatters/index.d.ts +11 -11
  182. package/lib/components/helpers/formatters/index.d.ts.map +1 -1
  183. package/lib/components/helpers/formatters/index.js.map +1 -1
  184. package/lib/components/helpers/simpleTableHelpers.d.ts +3 -1
  185. package/lib/components/helpers/simpleTableHelpers.d.ts.map +1 -1
  186. package/lib/components/helpers/simpleTableHelpers.js +5 -3
  187. package/lib/components/helpers/simpleTableHelpers.js.map +1 -1
  188. package/lib/components/helpers/state-utils.d.ts.map +1 -1
  189. package/lib/components/helpers/state-utils.js.map +1 -1
  190. package/lib/components/helpers/template-utils.d.ts +7 -3
  191. package/lib/components/helpers/template-utils.d.ts.map +1 -1
  192. package/lib/components/helpers/template-utils.js +1 -0
  193. package/lib/components/helpers/template-utils.js.map +1 -1
  194. package/lib/components/helpers/versionHelpers.d.ts +6 -0
  195. package/lib/components/helpers/versionHelpers.d.ts.map +1 -1
  196. package/lib/components/helpers/versionHelpers.js +6 -0
  197. package/lib/components/helpers/versionHelpers.js.map +1 -1
  198. package/lib/components/infra/ActionButtons/ActionButtons.d.ts +6 -13
  199. package/lib/components/infra/ActionButtons/ActionButtons.d.ts.map +1 -1
  200. package/lib/components/infra/ActionButtons/ActionButtons.js +1 -13
  201. package/lib/components/infra/ActionButtons/ActionButtons.js.map +1 -1
  202. package/lib/components/infra/Assignment/Assignment.d.ts +1 -16
  203. package/lib/components/infra/Assignment/Assignment.d.ts.map +1 -1
  204. package/lib/components/infra/Assignment/Assignment.js +23 -23
  205. package/lib/components/infra/Assignment/Assignment.js.map +1 -1
  206. package/lib/components/infra/AssignmentCard/AssignmentCard.d.ts +8 -14
  207. package/lib/components/infra/AssignmentCard/AssignmentCard.d.ts.map +1 -1
  208. package/lib/components/infra/AssignmentCard/AssignmentCard.js +3 -16
  209. package/lib/components/infra/AssignmentCard/AssignmentCard.js.map +1 -1
  210. package/lib/components/infra/Containers/FlowContainer/FlowContainer.d.ts +1 -21
  211. package/lib/components/infra/Containers/FlowContainer/FlowContainer.d.ts.map +1 -1
  212. package/lib/components/infra/Containers/FlowContainer/FlowContainer.js +41 -48
  213. package/lib/components/infra/Containers/FlowContainer/FlowContainer.js.map +1 -1
  214. package/lib/components/infra/Containers/FlowContainer/helpers.d.ts.map +1 -1
  215. package/lib/components/infra/Containers/FlowContainer/helpers.js.map +1 -1
  216. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.d.ts +1 -17
  217. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.d.ts.map +1 -1
  218. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.js +4 -15
  219. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.js.map +1 -1
  220. package/lib/components/infra/Containers/ViewContainer/ViewContainer.d.ts +9 -22
  221. package/lib/components/infra/Containers/ViewContainer/ViewContainer.d.ts.map +1 -1
  222. package/lib/components/infra/Containers/ViewContainer/ViewContainer.js +9 -22
  223. package/lib/components/infra/Containers/ViewContainer/ViewContainer.js.map +1 -1
  224. package/lib/components/infra/DashboardFilter/DashboardFilter.d.ts +9 -19
  225. package/lib/components/infra/DashboardFilter/DashboardFilter.d.ts.map +1 -1
  226. package/lib/components/infra/DashboardFilter/DashboardFilter.js +2 -16
  227. package/lib/components/infra/DashboardFilter/DashboardFilter.js.map +1 -1
  228. package/lib/components/infra/DashboardFilter/filterUtils.d.ts.map +1 -1
  229. package/lib/components/infra/DashboardFilter/filterUtils.js +1 -1
  230. package/lib/components/infra/DashboardFilter/filterUtils.js.map +1 -1
  231. package/lib/components/infra/DeferLoad/DeferLoad.d.ts +1 -14
  232. package/lib/components/infra/DeferLoad/DeferLoad.d.ts.map +1 -1
  233. package/lib/components/infra/DeferLoad/DeferLoad.js +13 -15
  234. package/lib/components/infra/DeferLoad/DeferLoad.js.map +1 -1
  235. package/lib/components/infra/ErrorBoundary/ErrorBoundary.d.ts +5 -12
  236. package/lib/components/infra/ErrorBoundary/ErrorBoundary.d.ts.map +1 -1
  237. package/lib/components/infra/ErrorBoundary/ErrorBoundary.js +3 -13
  238. package/lib/components/infra/ErrorBoundary/ErrorBoundary.js.map +1 -1
  239. package/lib/components/infra/MultiStep/MultiStep.d.ts +11 -17
  240. package/lib/components/infra/MultiStep/MultiStep.d.ts.map +1 -1
  241. package/lib/components/infra/MultiStep/MultiStep.js +4 -18
  242. package/lib/components/infra/MultiStep/MultiStep.js.map +1 -1
  243. package/lib/components/infra/NavBar/NavBar.d.ts +8 -16
  244. package/lib/components/infra/NavBar/NavBar.d.ts.map +1 -1
  245. package/lib/components/infra/NavBar/NavBar.js +3 -16
  246. package/lib/components/infra/NavBar/NavBar.js.map +1 -1
  247. package/lib/components/infra/Reference/Reference.d.ts +1 -18
  248. package/lib/components/infra/Reference/Reference.d.ts.map +1 -1
  249. package/lib/components/infra/Reference/Reference.js +11 -16
  250. package/lib/components/infra/Reference/Reference.js.map +1 -1
  251. package/lib/components/infra/Region/Region.d.ts +4 -7
  252. package/lib/components/infra/Region/Region.d.ts.map +1 -1
  253. package/lib/components/infra/Region/Region.js +0 -4
  254. package/lib/components/infra/Region/Region.js.map +1 -1
  255. package/lib/components/infra/RootContainer/RootContainer.d.ts +1 -21
  256. package/lib/components/infra/RootContainer/RootContainer.d.ts.map +1 -1
  257. package/lib/components/infra/RootContainer/RootContainer.js +4 -21
  258. package/lib/components/infra/RootContainer/RootContainer.js.map +1 -1
  259. package/lib/components/infra/Stages/Stages.d.ts +5 -8
  260. package/lib/components/infra/Stages/Stages.d.ts.map +1 -1
  261. package/lib/components/infra/Stages/Stages.js +1 -6
  262. package/lib/components/infra/Stages/Stages.js.map +1 -1
  263. package/lib/components/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.d.ts.map +1 -1
  264. package/lib/components/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.js.map +1 -1
  265. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.d.ts +4 -10
  266. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.d.ts.map +1 -1
  267. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.js +4 -9
  268. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.js.map +1 -1
  269. package/lib/components/infra/View/View.d.ts +13 -16
  270. package/lib/components/infra/View/View.d.ts.map +1 -1
  271. package/lib/components/infra/View/View.js +4 -21
  272. package/lib/components/infra/View/View.js.map +1 -1
  273. package/lib/components/template/AppShell/AppShell.d.ts +20 -15
  274. package/lib/components/template/AppShell/AppShell.d.ts.map +1 -1
  275. package/lib/components/template/AppShell/AppShell.js +10 -22
  276. package/lib/components/template/AppShell/AppShell.js.map +1 -1
  277. package/lib/components/template/BannerPage/BannerPage.d.ts +11 -23
  278. package/lib/components/template/BannerPage/BannerPage.d.ts.map +1 -1
  279. package/lib/components/template/BannerPage/BannerPage.js +4 -22
  280. package/lib/components/template/BannerPage/BannerPage.js.map +1 -1
  281. package/lib/components/template/CaseSummary/CaseSummary.d.ts +5 -7
  282. package/lib/components/template/CaseSummary/CaseSummary.d.ts.map +1 -1
  283. package/lib/components/template/CaseSummary/CaseSummary.js +6 -6
  284. package/lib/components/template/CaseSummary/CaseSummary.js.map +1 -1
  285. package/lib/components/template/CaseView/CaseView.d.ts +10 -22
  286. package/lib/components/template/CaseView/CaseView.d.ts.map +1 -1
  287. package/lib/components/template/CaseView/CaseView.js +8 -21
  288. package/lib/components/template/CaseView/CaseView.js.map +1 -1
  289. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.d.ts +8 -15
  290. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.d.ts.map +1 -1
  291. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.js +0 -12
  292. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.js.map +1 -1
  293. package/lib/components/template/Confirmation/Confirmation.d.ts +10 -16
  294. package/lib/components/template/Confirmation/Confirmation.d.ts.map +1 -1
  295. package/lib/components/template/Confirmation/Confirmation.js +12 -23
  296. package/lib/components/template/Confirmation/Confirmation.js.map +1 -1
  297. package/lib/components/template/DataReference/DataReference.d.ts +15 -30
  298. package/lib/components/template/DataReference/DataReference.d.ts.map +1 -1
  299. package/lib/components/template/DataReference/DataReference.js +25 -48
  300. package/lib/components/template/DataReference/DataReference.js.map +1 -1
  301. package/lib/components/template/DefaultForm/DefaultForm.d.ts +1 -11
  302. package/lib/components/template/DefaultForm/DefaultForm.d.ts.map +1 -1
  303. package/lib/components/template/DefaultForm/DefaultForm.js +9 -10
  304. package/lib/components/template/DefaultForm/DefaultForm.js.map +1 -1
  305. package/lib/components/template/Details/Details/Details.d.ts +1 -16
  306. package/lib/components/template/Details/Details/Details.d.ts.map +1 -1
  307. package/lib/components/template/Details/Details/Details.js +10 -15
  308. package/lib/components/template/Details/Details/Details.js.map +1 -1
  309. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.d.ts +7 -15
  310. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.d.ts.map +1 -1
  311. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.js +1 -13
  312. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.js.map +1 -1
  313. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.d.ts +1 -16
  314. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.d.ts.map +1 -1
  315. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.js +14 -16
  316. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.js.map +1 -1
  317. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.d.ts +1 -16
  318. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.d.ts.map +1 -1
  319. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.js +14 -16
  320. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.js.map +1 -1
  321. package/lib/components/template/Details/DynamicTabs/DynamicTabs.d.ts +4 -0
  322. package/lib/components/template/Details/DynamicTabs/DynamicTabs.d.ts.map +1 -0
  323. package/lib/components/template/Details/DynamicTabs/DynamicTabs.js +56 -0
  324. package/lib/components/template/Details/DynamicTabs/DynamicTabs.js.map +1 -0
  325. package/lib/components/template/Details/DynamicTabs/index.d.ts +2 -0
  326. package/lib/components/template/Details/DynamicTabs/index.d.ts.map +1 -0
  327. package/lib/components/template/Details/DynamicTabs/index.js +2 -0
  328. package/lib/components/template/Details/DynamicTabs/index.js.map +1 -0
  329. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.d.ts +12 -19
  330. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.d.ts.map +1 -1
  331. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.js +7 -21
  332. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.js.map +1 -1
  333. package/lib/components/template/InlineDashboard/InlineDashboard.d.ts +7 -7
  334. package/lib/components/template/InlineDashboard/InlineDashboard.d.ts.map +1 -1
  335. package/lib/components/template/InlineDashboard/InlineDashboard.js +0 -5
  336. package/lib/components/template/InlineDashboard/InlineDashboard.js.map +1 -1
  337. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.d.ts +8 -15
  338. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.d.ts.map +1 -1
  339. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.js +6 -15
  340. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.js.map +1 -1
  341. package/lib/components/template/ListPage/ListPage.d.ts +5 -13
  342. package/lib/components/template/ListPage/ListPage.d.ts.map +1 -1
  343. package/lib/components/template/ListPage/ListPage.js +6 -10
  344. package/lib/components/template/ListPage/ListPage.js.map +1 -1
  345. package/lib/components/template/ListView/ListView.d.ts +1 -9
  346. package/lib/components/template/ListView/ListView.d.ts.map +1 -1
  347. package/lib/components/template/ListView/ListView.js +177 -192
  348. package/lib/components/template/ListView/ListView.js.map +1 -1
  349. package/lib/components/template/ListView/utils.d.ts +44 -0
  350. package/lib/components/template/ListView/utils.d.ts.map +1 -1
  351. package/lib/components/template/ListView/utils.js +142 -1
  352. package/lib/components/template/ListView/utils.js.map +1 -1
  353. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.d.ts +9 -13
  354. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.d.ts.map +1 -1
  355. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.js +2 -13
  356. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.js.map +1 -1
  357. package/lib/components/template/NarrowWide/NarrowWide/NarrowWide.d.ts +10 -1
  358. package/lib/components/template/NarrowWide/NarrowWide/NarrowWide.d.ts.map +1 -1
  359. package/lib/components/template/NarrowWide/NarrowWide/NarrowWide.js.map +1 -1
  360. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.d.ts +1 -16
  361. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.d.ts.map +1 -1
  362. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.js +14 -16
  363. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.js.map +1 -1
  364. package/lib/components/template/NarrowWide/NarrowWideForm/NarrowWideForm.d.ts +5 -1
  365. package/lib/components/template/NarrowWide/NarrowWideForm/NarrowWideForm.d.ts.map +1 -1
  366. package/lib/components/template/NarrowWide/NarrowWideForm/NarrowWideForm.js.map +1 -1
  367. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.d.ts +7 -14
  368. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.d.ts.map +1 -1
  369. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.js +4 -13
  370. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.js.map +1 -1
  371. package/lib/components/template/OneColumn/OneColumn/OneColumn.d.ts +4 -7
  372. package/lib/components/template/OneColumn/OneColumn/OneColumn.d.ts.map +1 -1
  373. package/lib/components/template/OneColumn/OneColumn/OneColumn.js +0 -5
  374. package/lib/components/template/OneColumn/OneColumn/OneColumn.js.map +1 -1
  375. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.d.ts +4 -8
  376. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.d.ts.map +1 -1
  377. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.js +3 -6
  378. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.js.map +1 -1
  379. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.d.ts +4 -7
  380. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.d.ts.map +1 -1
  381. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.js +0 -5
  382. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.js.map +1 -1
  383. package/lib/components/template/PromotedFilters/PromotedFilters.d.ts +1 -15
  384. package/lib/components/template/PromotedFilters/PromotedFilters.d.ts.map +1 -1
  385. package/lib/components/template/PromotedFilters/PromotedFilters.js +15 -11
  386. package/lib/components/template/PromotedFilters/PromotedFilters.js.map +1 -1
  387. package/lib/components/template/SimpleTable/SimpleTable/SimpleTable.d.ts.map +1 -1
  388. package/lib/components/template/SimpleTable/SimpleTable/SimpleTable.js +57 -5
  389. package/lib/components/template/SimpleTable/SimpleTable/SimpleTable.js.map +1 -1
  390. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.d.ts +18 -1
  391. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.d.ts.map +1 -1
  392. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.js +3 -3
  393. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.js.map +1 -1
  394. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.d.ts +1 -29
  395. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.d.ts.map +1 -1
  396. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.js +22 -28
  397. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.js.map +1 -1
  398. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.d.ts +14 -26
  399. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.d.ts.map +1 -1
  400. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.js +5 -26
  401. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.js.map +1 -1
  402. package/lib/components/template/SubTabs/SubTabs.d.ts +4 -10
  403. package/lib/components/template/SubTabs/SubTabs.d.ts.map +1 -1
  404. package/lib/components/template/SubTabs/SubTabs.js +1 -8
  405. package/lib/components/template/SubTabs/SubTabs.js.map +1 -1
  406. package/lib/components/template/SubTabs/tabUtils.d.ts.map +1 -1
  407. package/lib/components/template/SubTabs/tabUtils.js.map +1 -1
  408. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.d.ts +5 -11
  409. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.d.ts.map +1 -1
  410. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.js +1 -12
  411. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.js.map +1 -1
  412. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.d.ts +4 -8
  413. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.d.ts.map +1 -1
  414. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.js +3 -6
  415. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.js.map +1 -1
  416. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.d.ts +5 -11
  417. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.d.ts.map +1 -1
  418. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.js +1 -9
  419. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.js.map +1 -1
  420. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.d.ts +10 -1
  421. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.d.ts.map +1 -1
  422. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.js +1 -1
  423. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.js.map +1 -1
  424. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.d.ts +1 -16
  425. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.d.ts.map +1 -1
  426. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.js +31 -23
  427. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.js.map +1 -1
  428. package/lib/components/template/WideNarrow/WideNarrowForm/WideNarrowForm.d.ts +5 -1
  429. package/lib/components/template/WideNarrow/WideNarrowForm/WideNarrowForm.d.ts.map +1 -1
  430. package/lib/components/template/WideNarrow/WideNarrowForm/WideNarrowForm.js.map +1 -1
  431. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.d.ts +7 -14
  432. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.d.ts.map +1 -1
  433. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.js +4 -14
  434. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.js.map +1 -1
  435. package/lib/components/template/WssNavBar/WssNavBar.d.ts +17 -1
  436. package/lib/components/template/WssNavBar/WssNavBar.d.ts.map +1 -1
  437. package/lib/components/template/WssNavBar/WssNavBar.js.map +1 -1
  438. package/lib/components/widget/AppAnnouncement/AppAnnouncement.d.ts +8 -17
  439. package/lib/components/widget/AppAnnouncement/AppAnnouncement.d.ts.map +1 -1
  440. package/lib/components/widget/AppAnnouncement/AppAnnouncement.js +4 -19
  441. package/lib/components/widget/AppAnnouncement/AppAnnouncement.js.map +1 -1
  442. package/lib/components/widget/Attachment/Attachment.d.ts.map +1 -1
  443. package/lib/components/widget/Attachment/Attachment.js +24 -16
  444. package/lib/components/widget/Attachment/Attachment.js.map +1 -1
  445. package/lib/components/widget/CaseHistory/CaseHistory.d.ts +4 -7
  446. package/lib/components/widget/CaseHistory/CaseHistory.d.ts.map +1 -1
  447. package/lib/components/widget/CaseHistory/CaseHistory.js +4 -8
  448. package/lib/components/widget/CaseHistory/CaseHistory.js.map +1 -1
  449. package/lib/components/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.d.ts +8 -1
  450. package/lib/components/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.d.ts.map +1 -1
  451. package/lib/components/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.js.map +1 -1
  452. package/lib/components/widget/FileUtility/FileUtility/FileUtility.d.ts +5 -1
  453. package/lib/components/widget/FileUtility/FileUtility/FileUtility.d.ts.map +1 -1
  454. package/lib/components/widget/FileUtility/FileUtility/FileUtility.js +31 -21
  455. package/lib/components/widget/FileUtility/FileUtility/FileUtility.js.map +1 -1
  456. package/lib/components/widget/Followers/Followers.d.ts +4 -5
  457. package/lib/components/widget/Followers/Followers.d.ts.map +1 -1
  458. package/lib/components/widget/Followers/Followers.js +3 -10
  459. package/lib/components/widget/Followers/Followers.js.map +1 -1
  460. package/lib/components/widget/QuickCreate/QuickCreate.d.ts.map +1 -1
  461. package/lib/components/widget/QuickCreate/QuickCreate.js +10 -2
  462. package/lib/components/widget/QuickCreate/QuickCreate.js.map +1 -1
  463. package/lib/components/widget/SummaryItem/SummaryItem.d.ts +7 -1
  464. package/lib/components/widget/SummaryItem/SummaryItem.d.ts.map +1 -1
  465. package/lib/components/widget/SummaryItem/SummaryItem.js.map +1 -1
  466. package/lib/components/widget/SummaryList/SummaryList.d.ts +7 -1
  467. package/lib/components/widget/SummaryList/SummaryList.d.ts.map +1 -1
  468. package/lib/components/widget/SummaryList/SummaryList.js +5 -2
  469. package/lib/components/widget/SummaryList/SummaryList.js.map +1 -1
  470. package/lib/components/widget/ToDo/ToDo.d.ts +13 -27
  471. package/lib/components/widget/ToDo/ToDo.d.ts.map +1 -1
  472. package/lib/components/widget/ToDo/ToDo.js +28 -64
  473. package/lib/components/widget/ToDo/ToDo.js.map +1 -1
  474. package/lib/doc/KeyReleaseUpdates.md +22 -0
  475. package/lib/hooks/index.d.ts +4 -0
  476. package/lib/hooks/index.d.ts.map +1 -0
  477. package/lib/hooks/index.js +4 -0
  478. package/lib/hooks/index.js.map +1 -0
  479. package/lib/hooks/useAfterInitialEffect.d.ts +9 -0
  480. package/lib/hooks/useAfterInitialEffect.d.ts.map +1 -0
  481. package/lib/hooks/useAfterInitialEffect.js +16 -0
  482. package/lib/hooks/useAfterInitialEffect.js.map +1 -0
  483. package/lib/hooks/useConsolidatedRef.d.ts +9 -0
  484. package/lib/hooks/useConsolidatedRef.d.ts.map +1 -0
  485. package/lib/hooks/useConsolidatedRef.js +30 -0
  486. package/lib/hooks/useConsolidatedRef.js.map +1 -0
  487. package/lib/hooks/useUID.d.ts +8 -0
  488. package/lib/hooks/useUID.d.ts.map +1 -0
  489. package/lib/hooks/useUID.js +14 -0
  490. package/lib/hooks/useUID.js.map +1 -0
  491. package/lib/index.d.ts +1 -0
  492. package/lib/index.d.ts.map +1 -1
  493. package/lib/index.js +2 -1
  494. package/lib/index.js.map +1 -1
  495. package/lib/sdk-pega-component-map.d.ts +17 -1
  496. package/lib/sdk-pega-component-map.js +17 -1
  497. package/lib/sdk-pega-component-map.js.map +1 -1
  498. package/lib/types/PConnProps.d.ts +42 -0
  499. package/package.json +1 -1
@@ -1,204 +1,665 @@
1
1
  // This file wraps various calls related to logging in, logging out, etc.
2
2
  // that use the auth.html/auth.js to do the work of logging in via OAuth 2.0.
3
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
6
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7
+ };
8
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9
+ if (kind === "m") throw new TypeError("Private method is not writable");
10
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
11
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
12
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
13
+ };
14
+ var _AuthManager_instances, _AuthManager_ssKeyPrefix, _AuthManager_pegaAuth, _AuthManager_ssKeyConfigInfo, _AuthManager_ssKeySessionInfo, _AuthManager_ssKeyTokenInfo, _AuthManager_ssKeyState, _AuthManager_authConfig, _AuthManager_authDynState, _AuthManager_authHeader, _AuthManager_tokenInfo, _AuthManager_userInfo, _AuthManager_usePASS, _AuthManager_pageHideAdded, _AuthManager_tokenStorage, _AuthManager_transform, _AuthManager_foldSpot, _AuthManager_transformAndParse, _AuthManager_getStorage, _AuthManager_setStorage, _AuthManager_calcFoldSpot, _AuthManager_transformer, _AuthManager_doPageHide, _AuthManager_loadState, _AuthManager_doOnLoad, _AuthManager_doAuthDynStateChanged, _AuthManager_initialize, _AuthManager_constellationInit, _AuthManager_customConstellationInit, _AuthManager_fireTokenAvailable, _AuthManager_processTokenOnLogin, _AuthManager_updateLoginStatus, _AuthManager_authFullReauth, _AuthManager_authTokenUpdated;
15
+ // It utilizes a JS Class and private members to protect any sensitive tokens
16
+ // and token obfuscation routines
17
+ import { isEmptyObject } from './common-utils';
3
18
  import { getSdkConfig, SdkConfigAccess } from './config_access';
4
19
  import PegaAuth from './auth';
5
- // eslint-disable-next-line import/no-mutable-exports
6
- export let gbLoggedIn = sessionStorage.getItem('rsdk_AH') !== null;
7
- // eslint-disable-next-line import/no-mutable-exports
8
- export let gbLoginInProgress = sessionStorage.getItem("rsdk_loggingIn") !== null;
9
- // other sessionStorage items: rsdk_appName
10
- // will store the PegaAuth instance
11
- let authMgr = null;
12
- // Since this variable is loaded in a separate instance in the popup scenario, use storage to coordinate across the two
13
- let usePopupForRestOfSession = sessionStorage.getItem("rsdk_popup") === "1";
14
- let gbC11NBootstrapInProgress = false;
15
- // Some non Pega OAuth 2.0 Authentication in use (Basic or Custom for service package)
16
- let gbCustomAuth = false;
17
- /*
18
- * Set to use popup experience for rest of session
19
- */
20
- const forcePopupForReauths = (bForce) => {
21
- if (bForce) {
22
- sessionStorage.setItem("rsdk_popup", "1");
23
- usePopupForRestOfSession = true;
20
+ // Meant to be a singleton...only one instance per page
21
+ class AuthManager {
22
+ constructor() {
23
+ _AuthManager_instances.add(this);
24
+ _AuthManager_ssKeyPrefix.set(this, 'rs');
25
+ // will store the PegaAuth (OAuth 2.0 client library) instance
26
+ _AuthManager_pegaAuth.set(this, null);
27
+ _AuthManager_ssKeyConfigInfo.set(this, '');
28
+ _AuthManager_ssKeySessionInfo.set(this, '');
29
+ _AuthManager_ssKeyTokenInfo.set(this, '');
30
+ _AuthManager_ssKeyState.set(this, `${__classPrivateFieldGet(this, _AuthManager_ssKeyPrefix, "f")}State`);
31
+ _AuthManager_authConfig.set(this, {});
32
+ _AuthManager_authDynState.set(this, {});
33
+ _AuthManager_authHeader.set(this, null);
34
+ // state that should be persisted across loads
35
+ Object.defineProperty(this, "state", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: { usePopup: false, noInitialRedirect: false }
40
+ });
41
+ Object.defineProperty(this, "bC11NBootstrapInProgress", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: false
46
+ });
47
+ Object.defineProperty(this, "bCustomAuth", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: false
52
+ });
53
+ _AuthManager_tokenInfo.set(this, void 0);
54
+ _AuthManager_userInfo.set(this, void 0);
55
+ Object.defineProperty(this, "onLoadDone", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: false
60
+ });
61
+ Object.defineProperty(this, "msReauthStart", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: null
66
+ });
67
+ Object.defineProperty(this, "initInProgress", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: false
72
+ });
73
+ Object.defineProperty(this, "isLoggedIn", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: false
78
+ });
79
+ // Whether to pass a session storage key or structure to auth library
80
+ _AuthManager_usePASS.set(this, false);
81
+ _AuthManager_pageHideAdded.set(this, false);
82
+ _AuthManager_tokenStorage.set(this, 'temp');
83
+ _AuthManager_transform.set(this, true);
84
+ _AuthManager_foldSpot.set(this, 2);
85
+ // Auth Manager specific state is saved within session storage as important in redirect and popup window scenarios
86
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_loadState).call(this);
24
87
  }
25
- else {
26
- sessionStorage.removeItem("rsdk_popup");
27
- usePopupForRestOfSession = false;
88
+ // Setter for authHeader (no getter)
89
+ set authHeader(value) {
90
+ __classPrivateFieldSet(this, _AuthManager_authHeader, value, "f");
91
+ // setAuthorizationHeader method not available til 8.8 so do safety check
92
+ if (window.PCore?.getAuthUtils().setAuthorizationHeader) {
93
+ const authHdr = value === null ? '' : value;
94
+ window.PCore.getAuthUtils().setAuthorizationHeader(authHdr);
95
+ }
96
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_updateLoginStatus).call(this);
28
97
  }
29
- };
30
- const setNoInitialRedirect = (bNoInitialRedirect) => {
31
- if (bNoInitialRedirect) {
32
- forcePopupForReauths(true);
33
- sessionStorage.setItem("rsdk_noRedirect", "1");
98
+ // Setter/getter for usePopupForRestOfSession
99
+ set usePopupForRestOfSession(usePopup) {
100
+ this.state.usePopup = usePopup;
101
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
34
102
  }
35
- else {
36
- sessionStorage.removeItem("rsdk_noRedirect");
103
+ get usePopupForRestOfSession() {
104
+ return this.state.usePopup;
37
105
  }
38
- };
39
- const isLoginExpired = () => {
40
- let bExpired = true;
41
- const sLoginStart = sessionStorage.getItem("rsdk_loggingIn");
42
- if (sLoginStart !== null) {
43
- const currTime = Date.now();
44
- bExpired = currTime - parseInt(sLoginStart, 10) > 60000;
106
+ // Setter/getter for noInitialRedirect
107
+ set noInitialRedirect(bNoInitialRedirect) {
108
+ if (bNoInitialRedirect) {
109
+ this.usePopupForRestOfSession = true;
110
+ }
111
+ this.state.noInitialRedirect = bNoInitialRedirect;
112
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
45
113
  }
46
- return bExpired;
47
- };
48
- /**
49
- * Clean up any web storage allocated for the user session.
50
- */
51
- const clearAuthMgr = (bFullReauth = false) => {
52
- // Remove any local storage for the user
53
- if (!gbCustomAuth) {
54
- sessionStorage.removeItem('rsdk_AH');
55
- }
56
- if (!bFullReauth) {
57
- sessionStorage.removeItem("rsdk_CI");
58
- }
59
- sessionStorage.removeItem("rsdk_TI");
60
- sessionStorage.removeItem("rsdk_UI");
61
- sessionStorage.removeItem("rsdk_loggingIn");
62
- gbLoggedIn = false;
63
- gbLoginInProgress = false;
64
- forcePopupForReauths(bFullReauth);
65
- // Not removing the authMgr structure itself...as it can be leveraged on next login
66
- };
67
- export const authNoRedirect = () => {
68
- return sessionStorage.getItem("rsdk_noRedirect") === "1";
69
- };
70
- /**
71
- * Initialize OAuth config structure members and create authMgr instance
72
- * bInit - governs whether to create new sessionStorage or load existing one
73
- */
74
- const initOAuth = (bInit) => {
75
- return getSdkConfig().then(sdkConfig => {
76
- const sdkConfigAuth = sdkConfig.authConfig;
77
- const sdkConfigServer = sdkConfig.serverConfig;
78
- let pegaUrl = sdkConfigServer.infinityRestServerUrl;
79
- const bNoInitialRedirect = authNoRedirect();
80
- // Construct default OAuth endpoints (if not explicitly specified)
81
- if (pegaUrl) {
82
- // Cope with trailing slash being present
83
- if (!pegaUrl.endsWith('/')) {
84
- pegaUrl += '/';
85
- }
86
- if (!sdkConfigAuth.authorize) {
87
- sdkConfigAuth.authorize = `${pegaUrl}PRRestService/oauth2/v1/authorize`;
88
- }
89
- if (!sdkConfigAuth.token) {
90
- sdkConfigAuth.token = `${pegaUrl}PRRestService/oauth2/v1/token`;
91
- }
92
- if (!sdkConfigAuth.revoke) {
93
- sdkConfigAuth.revoke = `${pegaUrl}PRRestService/oauth2/v1/revoke`;
94
- }
95
- if (!sdkConfigAuth.redirectUri) {
96
- sdkConfigAuth.redirectUri = `${window.location.origin}${window.location.pathname}`;
97
- }
98
- if (!sdkConfigAuth.userinfo) {
99
- const appAliasSeg = sdkConfigServer.appAlias ? `app/${sdkConfigServer.appAlias}/` : '';
100
- sdkConfigAuth.userinfo = `${pegaUrl}${appAliasSeg}api/oauthclients/v1/userinfo/JSON`;
101
- }
114
+ get noInitialRedirect() {
115
+ return this.state.noInitialRedirect || false;
116
+ }
117
+ // Init/getter for loginStart
118
+ set loginStart(msValue) {
119
+ if (msValue) {
120
+ this.state.msLoginStart = msValue;
102
121
  }
103
- // Auth service alias
104
- if (!sdkConfigAuth.authService) {
105
- sdkConfigAuth.authService = "pega";
122
+ else if (this.state.msLoginStart) {
123
+ delete this.state.msLoginStart;
106
124
  }
107
- // Construct path to auth.html (used for case when not doing a main window redirect)
108
- let sNoMainRedirectUri = sdkConfigAuth.redirectUri;
109
- const nLastPathSep = sNoMainRedirectUri.lastIndexOf("/");
110
- sNoMainRedirectUri = nLastPathSep !== -1 ? `${sNoMainRedirectUri.substring(0, nLastPathSep + 1)}auth.html` : `${sNoMainRedirectUri}/auth.html`;
111
- const authConfig = {
112
- clientId: bNoInitialRedirect ? sdkConfigAuth.mashupClientId : sdkConfigAuth.portalClientId,
113
- authorizeUri: sdkConfigAuth.authorize,
114
- tokenUri: sdkConfigAuth.token,
115
- revokeUri: sdkConfigAuth.revoke,
116
- userinfoUri: sdkConfigAuth.userinfo,
117
- redirectUri: bNoInitialRedirect || usePopupForRestOfSession
118
- ? sNoMainRedirectUri
119
- : sdkConfigAuth.redirectUri,
120
- authService: sdkConfigAuth.authService,
121
- appAlias: sdkConfigServer.appAlias || '',
122
- useLocking: true
123
- };
124
- // If no clientId is specified assume not OAuth but custom auth
125
- if (!authConfig.clientId) {
126
- gbCustomAuth = true;
127
- return;
125
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
126
+ }
127
+ get loginStart() {
128
+ return this.state.msLoginStart || 0;
129
+ }
130
+ // Init/getter for reauthStart
131
+ set reauthStart(msValue) {
132
+ if (msValue) {
133
+ this.msReauthStart = msValue;
128
134
  }
129
- if ('silentTimeout' in sdkConfigAuth) {
130
- authConfig.silentTimeout = sdkConfigAuth.silentTimeout;
135
+ else if (this.msReauthStart) {
136
+ delete this.msReauthStart;
131
137
  }
132
- if (bNoInitialRedirect && sdkConfigAuth.mashupUserIdentifier && sdkConfigAuth.mashupPassword) {
133
- authConfig.userIdentifier = sdkConfigAuth.mashupUserIdentifier;
134
- authConfig.password = sdkConfigAuth.mashupPassword;
138
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
139
+ }
140
+ get reauthStart() {
141
+ return this.msReauthStart || 0;
142
+ }
143
+ // Setter for clientId
144
+ set keySuffix(s) {
145
+ this.state.sfx = s || undefined;
146
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
147
+ if (s) {
148
+ // To make it a bit more obtuse reverse the string and use that as the actual suffix
149
+ const sSfx = s.split("").reverse().join("");
150
+ __classPrivateFieldSet(this, _AuthManager_ssKeyConfigInfo, `${__classPrivateFieldGet(this, _AuthManager_ssKeyPrefix, "f")}CI_${sSfx}`, "f");
151
+ __classPrivateFieldSet(this, _AuthManager_ssKeySessionInfo, `${__classPrivateFieldGet(this, _AuthManager_ssKeyPrefix, "f")}SI_${sSfx}`, "f");
152
+ __classPrivateFieldSet(this, _AuthManager_ssKeyTokenInfo, `${__classPrivateFieldGet(this, _AuthManager_ssKeyPrefix, "f")}TI_${sSfx}`, "f");
153
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_calcFoldSpot).call(this, sSfx);
135
154
  }
136
- if ('iframeLoginUI' in sdkConfigAuth) {
137
- authConfig.iframeLoginUI = sdkConfigAuth.iframeLoginUI.toString().toLowerCase() === 'true';
155
+ }
156
+ isLoginExpired() {
157
+ let bExpired = true;
158
+ if (this.loginStart) {
159
+ const currTime = Date.now();
160
+ bExpired = currTime - this.loginStart > 60000;
161
+ }
162
+ return bExpired;
163
+ }
164
+ /**
165
+ * Clean up any session storage allocated for the user session.
166
+ */
167
+ clear(bFullReauth = false) {
168
+ if (!this.bCustomAuth) {
169
+ __classPrivateFieldSet(this, _AuthManager_authHeader, null, "f");
170
+ }
171
+ if (!bFullReauth) {
172
+ if (__classPrivateFieldGet(this, _AuthManager_usePASS, "f")) {
173
+ sessionStorage.removeItem(__classPrivateFieldGet(this, _AuthManager_ssKeyConfigInfo, "f"));
174
+ }
175
+ else {
176
+ __classPrivateFieldSet(this, _AuthManager_authConfig, {}, "f");
177
+ __classPrivateFieldSet(this, _AuthManager_authDynState, {}, "f");
178
+ }
179
+ sessionStorage.removeItem(__classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f"));
138
180
  }
139
- // Check if sessionStorage exists (and if so if for same authorize endpoint). Otherwise, assume
140
- // sessionStorage is out of date (user just edited endpoints). Else, logout required to clear
141
- // sessionStorage and get other endpoints updates.
142
- // Doing this as sessionIndex might have been added to this storage structure
143
- let sSI = sessionStorage.getItem("rsdk_CI");
144
- if (sSI) {
145
- try {
146
- const oSI = JSON.parse(sSI);
147
- const aProps = ['authorizeUri', 'appAlias', 'clientId', 'authService', 'userIdentifier'];
148
- for (let i = 0; i < aProps.length; i += 1) {
149
- const prop = aProps[i];
150
- const currValue = oSI[prop];
151
- const newValue = authConfig[prop];
152
- if (currValue !== newValue) {
181
+ // Clear any established auth tokens
182
+ __classPrivateFieldSet(this, _AuthManager_tokenInfo, null, "f");
183
+ sessionStorage.removeItem(__classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f"));
184
+ this.loginStart = 0;
185
+ this.isLoggedIn = false;
186
+ // reset the initial redirect as well by using this setter
187
+ this.usePopupForRestOfSession = bFullReauth;
188
+ this.keySuffix = '';
189
+ }
190
+ updateRedirectUri(sRedirectUri) {
191
+ __classPrivateFieldGet(this, _AuthManager_authConfig, "f").redirectUri = sRedirectUri;
192
+ }
193
+ /**
194
+ * Get available portals which supports SDK
195
+ * @returns list of available portals (portals other than excludingPortals list)
196
+ */
197
+ async getAvailablePortals() {
198
+ return getSdkConfig().then(sdkConfig => {
199
+ const serverConfig = sdkConfig.serverConfig;
200
+ const userAccessGroup = PCore.getEnvironmentInfo().getAccessGroup();
201
+ const dataPageName = 'D_OperatorAccessGroups';
202
+ const serverUrl = serverConfig.infinityRestServerUrl;
203
+ const appAlias = serverConfig.appAlias;
204
+ const appAliasPath = appAlias ? `/app/${appAlias}` : '';
205
+ const arExcludedPortals = serverConfig['excludePortals'];
206
+ const headers = {
207
+ Authorization: __classPrivateFieldGet(this, _AuthManager_authHeader, "f") === null ? '' : __classPrivateFieldGet(this, _AuthManager_authHeader, "f"),
208
+ 'Content-Type': 'application/json'
209
+ };
210
+ // Using v1 API here as v2 data_views is not able to access same data page currently. Should move to avoid having this logic to find
211
+ // a default portal or constellation portal and rather have Constellation JS Engine API just load the default portal
212
+ return fetch(`${serverUrl}${appAliasPath}/api/v1/data/${dataPageName}`, {
213
+ method: 'GET',
214
+ headers
215
+ })
216
+ .then(response => {
217
+ if (response.ok && response.status === 200) {
218
+ return response.json();
219
+ }
220
+ else {
221
+ if (response.status === 401) {
222
+ // Might be either a real token expiration or revoke, but more likely that the "api" service package is misconfigured
223
+ throw new Error(`Attempt to access ${dataPageName} failed. The "api" service package is likely not configured to use "OAuth 2.0"`);
224
+ }
225
+ throw new Error(`HTTP Error: ${response.status}`);
226
+ }
227
+ })
228
+ .then(async (agData) => {
229
+ const arAccessGroups = agData.pxResults;
230
+ const availablePortals = [];
231
+ for (const ag of arAccessGroups) {
232
+ if (ag.pyAccessGroup === userAccessGroup) {
153
233
  // eslint-disable-next-line no-console
154
- console.warn(`Clearing credentials due to mismatch for property: ${prop};` +
155
- `currValue (${currValue}) does not match new desired value (${newValue})`);
156
- clearAuthMgr();
157
- sSI = null;
234
+ console.error(`Default portal for current operator (${ag.pyPortal}) is not compatible with SDK.\nConsider using a different operator, adjusting the default portal for this operator, or using "appPortal" setting within sdk-config.json to specify a specific portal to load.`);
235
+ let portal = null;
236
+ for (portal of ag.pyUserPortals) {
237
+ if (!arExcludedPortals.includes(portal.pyPortalLayout)) {
238
+ availablePortals.push(portal.pyPortalLayout);
239
+ }
240
+ }
158
241
  break;
159
242
  }
160
243
  }
244
+ // Found operator's current access group. Use its portal
245
+ // eslint-disable-next-line no-console
246
+ console.log(`Available portals: ${availablePortals}`);
247
+ return availablePortals;
248
+ })
249
+ .catch(e => {
250
+ // eslint-disable-next-line no-console
251
+ console.error(e.message);
252
+ // check specific error if 401, and wiped out if so stored token is stale. Fetch new tokens.
253
+ });
254
+ });
255
+ }
256
+ ;
257
+ // TODO: Cope with 401 and refresh token if possible (or just hope that it succeeds during login)
258
+ /**
259
+ * Retrieve UserInfo for current authentication service
260
+ */
261
+ getUserInfo() {
262
+ if (__classPrivateFieldGet(this, _AuthManager_userInfo, "f")) {
263
+ return __classPrivateFieldGet(this, _AuthManager_userInfo, "f");
264
+ }
265
+ return __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_initialize).call(this, false).then((aMgr) => {
266
+ return aMgr.getUserinfo(__classPrivateFieldGet(this, _AuthManager_tokenInfo, "f").access_token).then(data => {
267
+ __classPrivateFieldSet(this, _AuthManager_userInfo, data, "f");
268
+ return __classPrivateFieldGet(this, _AuthManager_userInfo, "f");
269
+ });
270
+ });
271
+ }
272
+ login(bFullReauth = false) {
273
+ if (this.bCustomAuth)
274
+ return;
275
+ // Needed so a redirect to login screen and back will know we are still in process of logging in
276
+ this.loginStart = Date.now();
277
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_initialize).call(this, !bFullReauth).then((aMgr) => {
278
+ const bMainRedirect = !this.noInitialRedirect;
279
+ const sdkConfigAuth = SdkConfigAccess.getSdkConfigAuth();
280
+ let sRedirectUri = sdkConfigAuth.redirectUri;
281
+ // If initial main redirect is OK, redirect to main page, otherwise will authorize in a popup window
282
+ if (bMainRedirect && !bFullReauth) {
283
+ // update redirect uri to be the root
284
+ this.updateRedirectUri(sRedirectUri);
285
+ aMgr.loginRedirect();
286
+ // Don't have token til after the redirect
287
+ return Promise.resolve(undefined);
161
288
  }
162
- catch (e) {
163
- // do nothing
289
+ else {
290
+ // Construct path to redirect uri
291
+ const nLastPathSep = sRedirectUri.lastIndexOf("/");
292
+ sRedirectUri = nLastPathSep !== -1 ? `${sRedirectUri.substring(0, nLastPathSep + 1)}auth.html` : `${sRedirectUri}/auth.html`;
293
+ // Set redirectUri to static auth.html
294
+ this.updateRedirectUri(sRedirectUri);
295
+ return new Promise((resolve, reject) => {
296
+ aMgr.login().then(token => {
297
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_processTokenOnLogin).call(this, token);
298
+ // this.getUserInfo();
299
+ resolve(token.access_token);
300
+ }).catch((e) => {
301
+ // Use setter to update state
302
+ this.loginStart = 0;
303
+ // eslint-disable-next-line no-console
304
+ console.log(e);
305
+ reject(e);
306
+ });
307
+ });
164
308
  }
309
+ });
310
+ }
311
+ authRedirectCallback(href, fnLoggedInCB = null) {
312
+ // Get code from href and swap for token
313
+ const aHrefParts = href.split('?');
314
+ const urlParams = new URLSearchParams(aHrefParts.length > 1 ? `?${aHrefParts[1]}` : '');
315
+ const code = urlParams.get('code');
316
+ const state = urlParams.get('state');
317
+ // If state should also match before accepting code
318
+ if (code) {
319
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_initialize).call(this, false).then((aMgr) => {
320
+ if (aMgr.checkStateMatch(state)) {
321
+ aMgr.getToken(code).then(token => {
322
+ if (token && token.access_token) {
323
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_processTokenOnLogin).call(this, token, false);
324
+ // this.getUserInfo();
325
+ if (fnLoggedInCB) {
326
+ fnLoggedInCB(token.access_token);
327
+ }
328
+ }
329
+ });
330
+ }
331
+ });
165
332
  }
166
- if (!sSI || bInit) {
167
- sessionStorage.setItem('rsdk_CI', JSON.stringify(authConfig));
333
+ else {
334
+ const error = urlParams.get('error');
335
+ const errorDesc = urlParams.get('errorDesc');
336
+ fnLoggedInCB(null, error, errorDesc);
168
337
  }
169
- authMgr = new PegaAuth('rsdk_CI');
170
- });
171
- };
172
- const getAuthMgr = (bInit) => {
173
- return new Promise((resolve) => {
174
- let idNextCheck = null;
175
- const fnCheckForAuthMgr = () => {
176
- if (PegaAuth && !authMgr) {
177
- initOAuth(bInit);
338
+ }
339
+ loginIfNecessary(loginProps) {
340
+ const { appName, deferLogin, redirectDoneCB } = loginProps;
341
+ const noMainRedirect = !loginProps.mainRedirect;
342
+ // We need to load state before making any decisions
343
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_loadState).call(this);
344
+ // If no initial redirect status of page changed...clear AuthMgr
345
+ const currNoMainRedirect = this.noInitialRedirect;
346
+ if (appName !== this.state.appName || noMainRedirect !== currNoMainRedirect) {
347
+ this.clear(false);
348
+ this.state.appName = appName;
349
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
350
+ }
351
+ this.noInitialRedirect = noMainRedirect;
352
+ // If custom auth no need to do any OAuth logic
353
+ if (this.bCustomAuth) {
354
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_updateLoginStatus).call(this);
355
+ if (!window.PCore) {
356
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_customConstellationInit).call(this, () => {
357
+ // Fire the SdkCustomReauth event to indicate a new authHeader is needed. Event listener should invoke sdkSetAuthHeader
358
+ // to communicate the new token to sdk (and Constellation JS Engine)
359
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
360
+ const event = new CustomEvent('SdkCustomReauth', { detail: sdkSetAuthHeader });
361
+ document.dispatchEvent(event);
362
+ });
178
363
  }
179
- if (authMgr) {
180
- if (idNextCheck) {
181
- clearInterval(idNextCheck);
364
+ return;
365
+ }
366
+ if (window.location.href.includes("?code")) {
367
+ // initialize authMgr (now initialize in constructor?)
368
+ return __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_initialize).call(this, false).then(() => {
369
+ const cbDefault = () => {
370
+ window.location.href = window.location.pathname;
371
+ };
372
+ // eslint-disable-next-line no-console
373
+ console.log('About to invoke PegaAuth authRedirectCallback');
374
+ this.authRedirectCallback(window.location.href, redirectDoneCB || cbDefault);
375
+ // });
376
+ });
377
+ }
378
+ if (!deferLogin && (!this.loginStart || this.isLoginExpired())) {
379
+ return __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_initialize).call(this, false).then(() => {
380
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_updateLoginStatus).call(this);
381
+ if (this.isLoggedIn) {
382
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_fireTokenAvailable).call(this, __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f"));
383
+ // this.getUserInfo();
384
+ }
385
+ else {
386
+ return this.login();
182
387
  }
183
- return resolve(authMgr);
388
+ // });
389
+ });
390
+ }
391
+ }
392
+ logout() {
393
+ sessionStorage.removeItem('rsdk_portalName');
394
+ return new Promise((resolve) => {
395
+ const fnClearAndResolve = () => {
396
+ this.clear();
397
+ const event = new Event('SdkLoggedOut');
398
+ document.dispatchEvent(event);
399
+ resolve(null);
400
+ };
401
+ if (this.bCustomAuth) {
402
+ fnClearAndResolve();
403
+ return;
184
404
  }
185
- };
186
- fnCheckForAuthMgr();
187
- idNextCheck = setInterval(fnCheckForAuthMgr, 10);
188
- });
189
- };
190
- export const sdkGetAuthHeader = () => {
191
- return sessionStorage.getItem("rsdk_AH");
192
- };
405
+ if (__classPrivateFieldGet(this, _AuthManager_tokenInfo, "f") && __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f").access_token) {
406
+ if (window.PCore) {
407
+ window.PCore.getAuthUtils().revokeTokens().then(() => {
408
+ fnClearAndResolve();
409
+ }).catch(err => {
410
+ // eslint-disable-next-line no-console
411
+ console.log("Error:", err?.message);
412
+ });
413
+ }
414
+ else {
415
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_initialize).call(this, false).then((aMgr) => {
416
+ aMgr.revokeTokens(__classPrivateFieldGet(this, _AuthManager_tokenInfo, "f").access_token, __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f").refresh_token)
417
+ .then(() => {
418
+ // Go to finally
419
+ })
420
+ .finally(() => {
421
+ fnClearAndResolve();
422
+ });
423
+ });
424
+ }
425
+ }
426
+ else {
427
+ fnClearAndResolve();
428
+ }
429
+ });
430
+ }
431
+ }
432
+ _AuthManager_ssKeyPrefix = new WeakMap(), _AuthManager_pegaAuth = new WeakMap(), _AuthManager_ssKeyConfigInfo = new WeakMap(), _AuthManager_ssKeySessionInfo = new WeakMap(), _AuthManager_ssKeyTokenInfo = new WeakMap(), _AuthManager_ssKeyState = new WeakMap(), _AuthManager_authConfig = new WeakMap(), _AuthManager_authDynState = new WeakMap(), _AuthManager_authHeader = new WeakMap(), _AuthManager_tokenInfo = new WeakMap(), _AuthManager_userInfo = new WeakMap(), _AuthManager_usePASS = new WeakMap(), _AuthManager_pageHideAdded = new WeakMap(), _AuthManager_tokenStorage = new WeakMap(), _AuthManager_transform = new WeakMap(), _AuthManager_foldSpot = new WeakMap(), _AuthManager_instances = new WeakSet(), _AuthManager_transformAndParse = function _AuthManager_transformAndParse(ssKey, ssItem, bForce = false) {
433
+ let obj = {};
434
+ try {
435
+ obj = JSON.parse(__classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_transformer).call(this, ssKey, ssItem, false, bForce));
436
+ }
437
+ catch (e) {
438
+ // fall thru and return empty object
439
+ }
440
+ return obj;
441
+ }, _AuthManager_getStorage = function _AuthManager_getStorage(ssKey, sAttrib = null) {
442
+ const ssItem = ssKey ? window.sessionStorage.getItem(ssKey) : null;
443
+ let obj = {};
444
+ if (ssItem) {
445
+ try {
446
+ obj = JSON.parse(ssItem);
447
+ }
448
+ catch (e) {
449
+ obj = __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_transformAndParse).call(this, ssKey, ssItem, true);
450
+ }
451
+ }
452
+ return sAttrib ? obj[sAttrib] : obj;
453
+ }, _AuthManager_setStorage = function _AuthManager_setStorage(ssKey, obj) {
454
+ // Set storage only if obj is not empty, else delete the storage
455
+ if (!obj || isEmptyObject(obj)) {
456
+ window.sessionStorage.removeItem(ssKey);
457
+ }
458
+ else {
459
+ // const bClear = (ssKey === this.#ssKeyState || ssKey === this.#ssKeySessionInfo);
460
+ const bClear = false;
461
+ const sValue = bClear ? JSON.stringify(obj) : __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_transformer).call(this, ssKey, JSON.stringify(obj), true);
462
+ window.sessionStorage.setItem(ssKey, sValue);
463
+ }
464
+ }, _AuthManager_calcFoldSpot = function _AuthManager_calcFoldSpot(s) {
465
+ const nOffset = 1;
466
+ const sChar = s.length > nOffset ? s.charAt(nOffset) : '2';
467
+ const nSpot = parseInt(sChar, 10);
468
+ __classPrivateFieldSet(this, _AuthManager_foldSpot, Number.isNaN(nSpot) ? 2 : (nSpot % 4) + 2, "f");
469
+ }, _AuthManager_transformer = function _AuthManager_transformer(ssKey, s, bIn, bForce = false) {
470
+ const bTransform = bForce || __classPrivateFieldGet(this, _AuthManager_transform, "f");
471
+ const fnFold = (x) => {
472
+ const nLen = x.length;
473
+ const nExtra = nLen % __classPrivateFieldGet(this, _AuthManager_foldSpot, "f");
474
+ const nOffset = Math.floor(nLen / __classPrivateFieldGet(this, _AuthManager_foldSpot, "f")) + nExtra;
475
+ const nRem = x.length - nOffset;
476
+ return x.substring(bIn ? nOffset : nRem) + x.substring(0, bIn ? nOffset : nRem);
477
+ };
478
+ const bTknInfo = ssKey === __classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f");
479
+ if (bTknInfo && !bIn && bTransform) {
480
+ s = window.atob(fnFold(s));
481
+ }
482
+ // eslint-disable-next-line no-nested-ternary
483
+ let result = bTransform ? (bIn ? window.btoa(s) : window.atob(s)) : s;
484
+ if (bTknInfo && bIn && bTransform) {
485
+ result = fnFold(window.btoa(result));
486
+ }
487
+ return result;
488
+ }, _AuthManager_doPageHide = function _AuthManager_doPageHide() {
489
+ // Safari and particularly Safari on mobile devices doesn't seem to load this on first main redirect or
490
+ // reliably, so have moved to having PegaAuth manage writing all state props to session storage
491
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"), this.state);
492
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f"), __classPrivateFieldGet(this, _AuthManager_authDynState, "f"));
493
+ // If tokenStorage was always, token would already be there
494
+ if (__classPrivateFieldGet(this, _AuthManager_tokenStorage, "f") === 'temp') {
495
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f"), __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f"));
496
+ }
497
+ }, _AuthManager_loadState = function _AuthManager_loadState() {
498
+ // Note: State storage key doesn't have a client id associated with it
499
+ const oState = __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_getStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyState, "f"));
500
+ if (oState) {
501
+ Object.assign(this.state, oState);
502
+ if (this.state.sfx) {
503
+ // Setter sets up the ssKey values as well
504
+ this.keySuffix = this.state.sfx;
505
+ }
506
+ }
507
+ }, _AuthManager_doOnLoad = function _AuthManager_doOnLoad() {
508
+ if (!this.onLoadDone) {
509
+ // This authConfig state doesn't collide with other calculated static state...so load it first
510
+ // Note: transform setting will have already been loaded into #authConfig at this point
511
+ __classPrivateFieldSet(this, _AuthManager_authDynState, __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_getStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f")), "f");
512
+ __classPrivateFieldSet(this, _AuthManager_tokenInfo, __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_getStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f")), "f");
513
+ if (__classPrivateFieldGet(this, _AuthManager_tokenStorage, "f") !== 'always') {
514
+ sessionStorage.removeItem(__classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f"));
515
+ sessionStorage.removeItem(__classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f"));
516
+ }
517
+ this.onLoadDone = true;
518
+ }
519
+ }, _AuthManager_doAuthDynStateChanged = function _AuthManager_doAuthDynStateChanged() {
520
+ // If tokenStorage is setup for always then always persist the auth dynamic state as well
521
+ if (__classPrivateFieldGet(this, _AuthManager_tokenStorage, "f") === 'always') {
522
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f"), __classPrivateFieldGet(this, _AuthManager_authDynState, "f"));
523
+ }
524
+ }, _AuthManager_initialize =
193
525
  /**
194
- * Initiate the process to get the Constellation bootstrap shell loaded and initialized
195
- * @param {Object} authConfig
196
- * @param {Object} tokenInfo
197
- * @param {Function} authTokenUpdated - callback invoked when Constellation JS Engine silently updates
198
- * an expired access_token
199
- * @param {Function} fnReauth - callback invoked when a full or custom reauth is needed
526
+ * Initialize OAuth config structure members and create authMgr instance (if necessary)
527
+ * bNew - governs whether to create new sessionStorage or load existing one
200
528
  */
201
- const constellationInit = (authConfig, tokenInfo, authTokenUpdated, fnReauth) => {
529
+ async function _AuthManager_initialize(bNew = false) {
530
+ return new Promise((resolve) => {
531
+ if (!this.initInProgress && (bNew || isEmptyObject(__classPrivateFieldGet(this, _AuthManager_authConfig, "f")) || !__classPrivateFieldGet(this, _AuthManager_pegaAuth, "f"))) {
532
+ this.initInProgress = true;
533
+ getSdkConfig().then(sdkConfig => {
534
+ const sdkConfigAuth = sdkConfig.authConfig;
535
+ const sdkConfigServer = sdkConfig.serverConfig;
536
+ let pegaUrl = sdkConfigServer.infinityRestServerUrl;
537
+ const bNoInitialRedirect = this.noInitialRedirect;
538
+ // Construct default OAuth endpoints (if not explicitly specified)
539
+ if (pegaUrl) {
540
+ // Cope with trailing slash being present
541
+ if (!pegaUrl.endsWith('/')) {
542
+ pegaUrl += '/';
543
+ }
544
+ if (!sdkConfigAuth.authorize) {
545
+ sdkConfigAuth.authorize = `${pegaUrl}PRRestService/oauth2/v1/authorize`;
546
+ }
547
+ if (!sdkConfigAuth.token) {
548
+ sdkConfigAuth.token = `${pegaUrl}PRRestService/oauth2/v1/token`;
549
+ }
550
+ if (!sdkConfigAuth.revoke) {
551
+ sdkConfigAuth.revoke = `${pegaUrl}PRRestService/oauth2/v1/revoke`;
552
+ }
553
+ if (!sdkConfigAuth.redirectUri) {
554
+ sdkConfigAuth.redirectUri = `${window.location.origin}${window.location.pathname}`;
555
+ }
556
+ if (!sdkConfigAuth.userinfo) {
557
+ const appAliasSeg = sdkConfigServer.appAlias ? `app/${sdkConfigServer.appAlias}/` : '';
558
+ sdkConfigAuth.userinfo = `${pegaUrl}${appAliasSeg}api/oauthclients/v1/userinfo/JSON`;
559
+ }
560
+ }
561
+ // Auth service alias
562
+ if (!sdkConfigAuth.authService) {
563
+ sdkConfigAuth.authService = "pega";
564
+ }
565
+ // mashupAuthService provides way to have a different auth service for embedded
566
+ if (!sdkConfigAuth.mashupAuthService) {
567
+ sdkConfigAuth.mashupAuthService = sdkConfigAuth.authService;
568
+ }
569
+ // Construct path to auth.html (used for case when not doing a main window redirect)
570
+ let sNoMainRedirectUri = sdkConfigAuth.redirectUri;
571
+ const nLastPathSep = sNoMainRedirectUri.lastIndexOf("/");
572
+ sNoMainRedirectUri = nLastPathSep !== -1 ? `${sNoMainRedirectUri.substring(0, nLastPathSep + 1)}auth.html` : `${sNoMainRedirectUri}/auth.html`;
573
+ const portalGrantType = sdkConfigAuth.portalGrantType || 'authCode';
574
+ const mashupGrantType = sdkConfigAuth.mashupGrantType || 'authCode';
575
+ const pegaAuthConfig = {
576
+ clientId: bNoInitialRedirect ? sdkConfigAuth.mashupClientId : sdkConfigAuth.portalClientId,
577
+ grantType: bNoInitialRedirect ? mashupGrantType : portalGrantType,
578
+ tokenUri: sdkConfigAuth.token,
579
+ revokeUri: sdkConfigAuth.revoke,
580
+ userinfoUri: sdkConfigAuth.userinfo,
581
+ authService: bNoInitialRedirect ? sdkConfigAuth.mashupAuthService : sdkConfigAuth.authService,
582
+ appAlias: sdkConfigServer.appAlias || '',
583
+ useLocking: true
584
+ };
585
+ // Invoke keySuffix setter
586
+ // Was using pegaAuthConfig.clientId as key but more secure to just use a random string as getting
587
+ // both a clientId and the refresh token could yield a new access token.
588
+ // Suffix is so we might in future move to an array of suffixes based on the appName, so might store
589
+ // both portal and embedded tokens/session info at same time
590
+ if (!this.state?.sfx) {
591
+ // Just using a random number to make the suffix unique on each session
592
+ this.keySuffix = `${Math.ceil(Math.random() * 100000000)}`;
593
+ }
594
+ __classPrivateFieldGet(this, _AuthManager_authConfig, "f").transform = sdkConfigAuth.transform !== undefined ? sdkConfigAuth.transform : __classPrivateFieldGet(this, _AuthManager_transform, "f");
595
+ // Using property in class as authConfig may be empty at times
596
+ __classPrivateFieldSet(this, _AuthManager_transform, __classPrivateFieldGet(this, _AuthManager_authConfig, "f").transform, "f");
597
+ if (sdkConfigAuth.tokenStorage !== undefined) {
598
+ __classPrivateFieldSet(this, _AuthManager_tokenStorage, sdkConfigAuth.tokenStorage, "f");
599
+ }
600
+ // Get latest state once client ids, transform and tokenStorage have been established
601
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_doOnLoad).call(this);
602
+ // If no clientId is specified assume not OAuth but custom auth
603
+ if (!pegaAuthConfig.clientId) {
604
+ this.bCustomAuth = true;
605
+ return;
606
+ }
607
+ if (pegaAuthConfig.grantType === 'authCode') {
608
+ const authCodeProps = {
609
+ authorizeUri: sdkConfigAuth.authorize,
610
+ // If we have already specified a redirect on the authorize redirect, we need to continue to use that
611
+ // on token endpoint
612
+ redirectUri: bNoInitialRedirect || this.usePopupForRestOfSession ? sNoMainRedirectUri : sdkConfigAuth.redirectUri
613
+ };
614
+ if ('silentTimeout' in sdkConfigAuth) {
615
+ authCodeProps.silentTimeout = sdkConfigAuth.silentTimeout;
616
+ }
617
+ if (bNoInitialRedirect && pegaAuthConfig.authService === 'pega' &&
618
+ sdkConfigAuth.mashupUserIdentifier && sdkConfigAuth.mashupPassword) {
619
+ authCodeProps.userIdentifier = sdkConfigAuth.mashupUserIdentifier;
620
+ authCodeProps.password = sdkConfigAuth.mashupPassword;
621
+ }
622
+ if ('iframeLoginUI' in sdkConfigAuth) {
623
+ authCodeProps.iframeLoginUI = sdkConfigAuth.iframeLoginUI.toString().toLowerCase() === 'true';
624
+ }
625
+ Object.assign(pegaAuthConfig, authCodeProps);
626
+ }
627
+ Object.assign(__classPrivateFieldGet(this, _AuthManager_authConfig, "f"), pegaAuthConfig);
628
+ // Add an on page hide handler to write out key properties that we want to survive a
629
+ // browser reload
630
+ if (!__classPrivateFieldGet(this, _AuthManager_pageHideAdded, "f") && (!__classPrivateFieldGet(this, _AuthManager_usePASS, "f") || __classPrivateFieldGet(this, _AuthManager_tokenStorage, "f") !== 'always')) {
631
+ window.addEventListener('pagehide', __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_doPageHide).bind(this));
632
+ __classPrivateFieldSet(this, _AuthManager_pageHideAdded, true, "f");
633
+ }
634
+ // Initialise PegaAuth OAuth 2.0 client library
635
+ if (__classPrivateFieldGet(this, _AuthManager_usePASS, "f")) {
636
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyConfigInfo, "f"), __classPrivateFieldGet(this, _AuthManager_authConfig, "f"));
637
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f"), __classPrivateFieldGet(this, _AuthManager_authDynState, "f"));
638
+ __classPrivateFieldSet(this, _AuthManager_pegaAuth, new PegaAuth(__classPrivateFieldGet(this, _AuthManager_ssKeyConfigInfo, "f"), __classPrivateFieldGet(this, _AuthManager_ssKeySessionInfo, "f")), "f");
639
+ }
640
+ else {
641
+ __classPrivateFieldGet(this, _AuthManager_authConfig, "f").fnDynStateChangedCB = __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_doAuthDynStateChanged).bind(this);
642
+ __classPrivateFieldSet(this, _AuthManager_pegaAuth, new PegaAuth(__classPrivateFieldGet(this, _AuthManager_authConfig, "f"), __classPrivateFieldGet(this, _AuthManager_authDynState, "f")), "f");
643
+ }
644
+ this.initInProgress = false;
645
+ resolve(__classPrivateFieldGet(this, _AuthManager_pegaAuth, "f"));
646
+ });
647
+ }
648
+ else {
649
+ let idNextCheck;
650
+ const fnCheckForAuthMgr = () => {
651
+ if (!this.initInProgress) {
652
+ if (idNextCheck) {
653
+ clearInterval(idNextCheck);
654
+ }
655
+ resolve(__classPrivateFieldGet(this, _AuthManager_pegaAuth, "f"));
656
+ }
657
+ };
658
+ fnCheckForAuthMgr();
659
+ idNextCheck = setInterval(fnCheckForAuthMgr, 100);
660
+ }
661
+ });
662
+ }, _AuthManager_constellationInit = function _AuthManager_constellationInit(authConfig, tokenInfo, authTokenUpdated, fnReauth) {
202
663
  const constellationBootConfig = {};
203
664
  const sdkConfigServer = SdkConfigAccess.getSdkConfigServer();
204
665
  // Set up constellationConfig with data that bootstrapWithAuthHeader expects
@@ -223,7 +684,7 @@ const constellationInit = (authConfig, tokenInfo, authTokenUpdated, fnReauth) =>
223
684
  tokenInfo,
224
685
  // Set whether we want constellation to try to do a full re-Auth or not ()
225
686
  // true doesn't seem to be working in SDK scenario so always passing false for now
226
- popupReauth: false /* !authNoRedirect() */,
687
+ popupReauth: false /* !this.noInitialRedirect */,
227
688
  client_id: authConfig.clientId,
228
689
  authentication_service: authConfig.authService,
229
690
  redirect_uri: authConfig.redirectUri,
@@ -233,19 +694,19 @@ const constellationInit = (authConfig, tokenInfo, authTokenUpdated, fnReauth) =>
233
694
  revoke: authConfig.revokeUri
234
695
  },
235
696
  // TODO: setup callback so we can update own storage
236
- onTokenRetrieval: authTokenUpdated
697
+ onTokenRetrieval: __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_authTokenUpdated).bind(this)
237
698
  };
238
699
  }
239
700
  else {
240
- constellationBootConfig.authorizationHeader = sdkGetAuthHeader();
701
+ constellationBootConfig.authorizationHeader = __classPrivateFieldGet(this, _AuthManager_authHeader, "f");
241
702
  }
242
703
  // Turn off dynamic load components (should be able to do it here instead of after load?)
243
704
  constellationBootConfig.dynamicLoadComponents = false;
244
- if (gbC11NBootstrapInProgress) {
705
+ if (this.bC11NBootstrapInProgress) {
245
706
  return;
246
707
  }
247
708
  else {
248
- gbC11NBootstrapInProgress = true;
709
+ this.bC11NBootstrapInProgress = true;
249
710
  }
250
711
  // Note that staticContentServerUrl already ends with a slash (see above), so no slash added.
251
712
  // In order to have this import succeed and to have it done with the webpackIgnore magic comment tag.
@@ -258,8 +719,8 @@ const constellationInit = (authConfig, tokenInfo, authTokenUpdated, fnReauth) =>
258
719
  window.myLoadDefaultPortal = bootstrapShell.loadDefaultPortal;
259
720
  bootstrapShell.bootstrapWithAuthHeader(constellationBootConfig, 'pega-root').then(() => {
260
721
  // eslint-disable-next-line no-console
261
- console.log('Bootstrap successful!');
262
- gbC11NBootstrapInProgress = false;
722
+ console.log('ConstellationJS bootstrap successful!');
723
+ this.bC11NBootstrapInProgress = false;
263
724
  // Setup listener for the reauth event
264
725
  if (tokenInfo) {
265
726
  PCore.getPubSubUtils().subscribe(PCore.getConstants().PUB_SUB_EVENTS.EVENT_FULL_REAUTH, fnReauth, "authFullReauth");
@@ -278,175 +739,94 @@ const constellationInit = (authConfig, tokenInfo, authTokenUpdated, fnReauth) =>
278
739
  .catch(e => {
279
740
  // Assume error caught is because token is not valid and attempt a full reauth
280
741
  // eslint-disable-next-line no-console
281
- console.error(`Constellation JS Engine bootstrap failed. ${e}`);
282
- gbC11NBootstrapInProgress = false;
742
+ console.error(`ConstellationJS bootstrap failed. ${e}`);
743
+ this.bC11NBootstrapInProgress = false;
283
744
  fnReauth();
284
745
  });
285
746
  });
286
747
  /* Ends here */
287
- };
288
- export const updateLoginStatus = () => {
289
- const sAuthHdr = sdkGetAuthHeader();
290
- gbLoggedIn = sAuthHdr && sAuthHdr.length > 0;
291
- };
292
- const getCurrentTokens = () => {
293
- let tokens = null;
294
- const sTI = sessionStorage.getItem('rsdk_TI');
295
- if (sTI) {
296
- try {
297
- tokens = JSON.parse(sTI);
298
- }
299
- catch (e) {
300
- tokens = null;
301
- }
302
- }
303
- return tokens;
304
- };
305
- const fireTokenAvailable = (token, bLoadC11N = true) => {
748
+ }, _AuthManager_customConstellationInit = function _AuthManager_customConstellationInit(fnReauth) {
749
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_constellationInit).call(this, null, null, null, fnReauth);
750
+ }, _AuthManager_fireTokenAvailable = function _AuthManager_fireTokenAvailable(token, bLoadC11N = true) {
306
751
  if (!token) {
307
752
  // This is used on page reload to load the token from sessionStorage and carry on
308
- token = getCurrentTokens();
753
+ token = __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f");
309
754
  if (!token) {
310
755
  return;
311
756
  }
312
757
  }
313
- sessionStorage.setItem('rsdk_AH', `${token.token_type} ${token.access_token}`);
314
- updateLoginStatus();
315
- // gbLoggedIn is getting updated in updateLoginStatus
316
- gbLoggedIn = true;
317
- gbLoginInProgress = false;
318
- sessionStorage.removeItem("rsdk_loggingIn");
319
- forcePopupForReauths(true);
320
- const sSI = sessionStorage.getItem("rsdk_CI");
321
- let authConfig = null;
322
- if (sSI) {
323
- try {
324
- authConfig = JSON.parse(sSI);
325
- }
326
- catch (e) {
327
- // do nothing
328
- }
758
+ __classPrivateFieldSet(this, _AuthManager_tokenInfo, token, "f");
759
+ if (__classPrivateFieldGet(this, _AuthManager_tokenStorage, "f") === 'always') {
760
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f"), __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f"));
329
761
  }
762
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_updateLoginStatus).call(this);
763
+ // this.isLoggedIn is getting updated in updateLoginStatus
764
+ this.isLoggedIn = true;
765
+ this.loginStart = 0;
766
+ this.usePopupForRestOfSession = true;
330
767
  if (!window.PCore && bLoadC11N) {
331
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
332
- constellationInit(authConfig, token, authTokenUpdated, authFullReauth);
768
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_constellationInit).call(this, __classPrivateFieldGet(this, _AuthManager_authConfig, "f"), token, __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_authTokenUpdated).bind(this), __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_authFullReauth).bind(this));
333
769
  }
334
770
  /*
335
- // Create and dispatch the SdkLoggedIn event to trigger constellationInit
336
- const event = new CustomEvent('SdkLoggedIn', { detail: { authConfig, tokenInfo: token } });
337
- document.dispatchEvent(event);
338
- */
339
- };
340
- const processTokenOnLogin = (token, bLoadC11N = true) => {
341
- sessionStorage.setItem("rsdk_TI", JSON.stringify(token));
771
+ // Create and dispatch the SdkLoggedIn event to trigger constellationInit
772
+ const event = new CustomEvent('SdkLoggedIn', { detail: { authConfig, tokenInfo: token } });
773
+ document.dispatchEvent(event);
774
+ */
775
+ }, _AuthManager_processTokenOnLogin = function _AuthManager_processTokenOnLogin(token, bLoadC11N = true) {
776
+ __classPrivateFieldSet(this, _AuthManager_tokenInfo, token, "f");
777
+ if (__classPrivateFieldGet(this, _AuthManager_tokenStorage, "f") === 'always') {
778
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_setStorage).call(this, __classPrivateFieldGet(this, _AuthManager_ssKeyTokenInfo, "f"), __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f"));
779
+ }
342
780
  if (window.PCore) {
343
- window.PCore.getAuthUtils().setTokens(token);
781
+ PCore.getAuthUtils().setTokens(token);
344
782
  }
345
783
  else {
346
- fireTokenAvailable(token, bLoadC11N);
784
+ __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_fireTokenAvailable).call(this, token, bLoadC11N);
347
785
  }
348
- };
349
- const updateRedirectUri = (aMgr, sRedirectUri) => {
350
- const sSI = sessionStorage.getItem("rsdk_CI");
351
- let authConfig = null;
352
- if (sSI) {
353
- try {
354
- authConfig = JSON.parse(sSI);
355
- }
356
- catch (e) {
357
- // do nothing
786
+ }, _AuthManager_updateLoginStatus = function _AuthManager_updateLoginStatus() {
787
+ if (!__classPrivateFieldGet(this, _AuthManager_authHeader, "f") && __classPrivateFieldGet(this, _AuthManager_tokenInfo, "f")?.access_token) {
788
+ // Use setter to set this securely
789
+ this.authHeader = `${__classPrivateFieldGet(this, _AuthManager_tokenInfo, "f").token_type} ${__classPrivateFieldGet(this, _AuthManager_tokenInfo, "f").access_token}`;
790
+ }
791
+ this.isLoggedIn = !!(__classPrivateFieldGet(this, _AuthManager_authHeader, "f") && __classPrivateFieldGet(this, _AuthManager_authHeader, "f").length > 0);
792
+ }, _AuthManager_authFullReauth = function _AuthManager_authFullReauth() {
793
+ const bHandleHere = true; // Other alternative is to raise an event and have someone else handle it
794
+ if (this.reauthStart) {
795
+ const reauthIgnoreInterval = 300000; // 5 minutes
796
+ const currTime = Date.now();
797
+ const bReauthInProgress = currTime - this.reauthStart <= reauthIgnoreInterval;
798
+ if (bReauthInProgress) {
799
+ return;
358
800
  }
359
801
  }
360
- authConfig.redirectUri = sRedirectUri;
361
- sessionStorage.setItem("rsdk_CI", JSON.stringify(authConfig));
362
- aMgr.reloadConfig();
802
+ if (bHandleHere) {
803
+ // Don't want to do a full clear of authMgr as will loose state props (like sessionIndex). Rather just clear the tokens
804
+ this.clear(true);
805
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
806
+ login(true);
807
+ }
808
+ else {
809
+ // Fire the SdkFullReauth event to indicate a new token is needed (PCore.getAuthUtils.setTokens method
810
+ // should be used to communicate the new token to Constellation JS Engine.
811
+ const event = new CustomEvent('SdkFullReauth', { detail: __classPrivateFieldGet(this, _AuthManager_instances, "m", _AuthManager_processTokenOnLogin).bind(this) });
812
+ document.dispatchEvent(event);
813
+ }
814
+ }, _AuthManager_authTokenUpdated = function _AuthManager_authTokenUpdated(tokenInfo) {
815
+ __classPrivateFieldSet(this, _AuthManager_tokenInfo, tokenInfo, "f");
363
816
  };
817
+ const gAuthMgr = new AuthManager();
364
818
  // TODO: Cope with 401 and refresh token if possible (or just hope that it succeeds during login)
365
819
  /**
366
820
  * Retrieve UserInfo for current authentication service
367
821
  */
368
- export const getUserInfo = (bUseSS = true) => {
369
- const ssUserInfo = sessionStorage.getItem("rsdk_UI");
370
- let userInfo = null;
371
- if (bUseSS && ssUserInfo) {
372
- try {
373
- userInfo = JSON.parse(ssUserInfo);
374
- return Promise.resolve(userInfo);
375
- }
376
- catch (e) {
377
- // do nothing
378
- }
379
- }
380
- getAuthMgr(false).then((aMgr) => {
381
- const tokenInfo = getCurrentTokens();
382
- return aMgr.getUserinfo(tokenInfo.access_token).then(data => {
383
- userInfo = data;
384
- if (userInfo) {
385
- sessionStorage.setItem("rsdk_UI", JSON.stringify(userInfo));
386
- }
387
- else {
388
- sessionStorage.removeItem("rsdk_UI");
389
- }
390
- return Promise.resolve(userInfo);
391
- });
392
- });
822
+ export const getUserInfo = () => {
823
+ return gAuthMgr.getUserInfo();
393
824
  };
394
825
  export const login = (bFullReauth = false) => {
395
- if (gbCustomAuth)
396
- return;
397
- gbLoginInProgress = true;
398
- // Needed so a redirect to login screen and back will know we are still in process of logging in
399
- sessionStorage.setItem("rsdk_loggingIn", `${Date.now()}`);
400
- getAuthMgr(!bFullReauth).then((aMgr) => {
401
- const bMainRedirect = !authNoRedirect();
402
- const sdkConfigAuth = SdkConfigAccess.getSdkConfigAuth();
403
- let sRedirectUri = sdkConfigAuth.redirectUri;
404
- // If initial main redirect is OK, redirect to main page, otherwise will authorize in a popup window
405
- if (bMainRedirect && !bFullReauth) {
406
- // update redirect uri to be the root
407
- updateRedirectUri(aMgr, sRedirectUri);
408
- aMgr.loginRedirect();
409
- // Don't have token til after the redirect
410
- return Promise.resolve(undefined);
411
- }
412
- else {
413
- // Construct path to redirect uri
414
- const nLastPathSep = sRedirectUri.lastIndexOf("/");
415
- sRedirectUri = nLastPathSep !== -1 ? `${sRedirectUri.substring(0, nLastPathSep + 1)}auth.html` : `${sRedirectUri}/auth.html`;
416
- // Set redirectUri to static auth.html
417
- updateRedirectUri(aMgr, sRedirectUri);
418
- return new Promise((resolve, reject) => {
419
- aMgr.login().then(token => {
420
- processTokenOnLogin(token);
421
- // getUserInfo();
422
- resolve(token.access_token);
423
- }).catch((e) => {
424
- gbLoginInProgress = false;
425
- sessionStorage.removeItem("rsdk_loggingIn");
426
- // eslint-disable-next-line no-console
427
- console.log(e);
428
- reject(e);
429
- });
430
- });
431
- }
432
- });
826
+ return gAuthMgr.login(bFullReauth);
433
827
  };
434
828
  export const authRedirectCallback = (href, fnLoggedInCB = null) => {
435
- // Get code from href and swap for token
436
- const aHrefParts = href.split('?');
437
- const urlParams = new URLSearchParams(aHrefParts.length > 1 ? `?${aHrefParts[1]}` : '');
438
- const code = urlParams.get("code");
439
- getAuthMgr(false).then((aMgr) => {
440
- aMgr.getToken(code).then(token => {
441
- if (token && token.access_token) {
442
- processTokenOnLogin(token, false);
443
- // getUserInfo();
444
- if (fnLoggedInCB) {
445
- fnLoggedInCB(token.access_token);
446
- }
447
- }
448
- });
449
- });
829
+ gAuthMgr.authRedirectCallback(href, fnLoggedInCB);
450
830
  };
451
831
  /**
452
832
  * Silent or visible login based on login status
@@ -455,138 +835,30 @@ export const authRedirectCallback = (href, fnLoggedInCB = null) => {
455
835
  * away from the main page
456
836
  * @param {boolean} deferLogin - defer logging in (if not already authenticated)
457
837
  */
458
- export const loginIfNecessary = (appName, noMainRedirect = false, deferLogin = false) => {
459
- // If no initial redirect status of page changed...clearAuthMgr
460
- const currNoMainRedirect = authNoRedirect();
461
- const currAppName = sessionStorage.getItem("rsdk_appName");
462
- if (appName !== currAppName || noMainRedirect !== currNoMainRedirect) {
463
- clearAuthMgr();
464
- sessionStorage.setItem("rsdk_appName", appName);
465
- }
466
- setNoInitialRedirect(noMainRedirect);
467
- // If custom auth no need to do any OAuth logic
468
- if (gbCustomAuth) {
469
- if (!window.PCore) {
470
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
471
- constellationInit(null, null, null, authCustomReauth);
472
- }
473
- return;
474
- }
475
- if (window.location.href.indexOf("?code") !== -1) {
476
- // initialize authMgr
477
- initOAuth(false);
478
- return getAuthMgr(false).then(() => {
479
- authRedirectCallback(window.location.href, () => {
480
- window.location.href = window.location.pathname;
481
- });
482
- });
483
- }
484
- if (!deferLogin && (!gbLoginInProgress || isLoginExpired())) {
485
- initOAuth(false);
486
- return getAuthMgr(false).then(() => {
487
- updateLoginStatus();
488
- if (gbLoggedIn) {
489
- fireTokenAvailable(getCurrentTokens());
490
- // getUserInfo();
491
- }
492
- else {
493
- return login();
494
- }
495
- });
496
- }
838
+ export const loginIfNecessary = (loginProps) => {
839
+ gAuthMgr.loginIfNecessary(loginProps);
497
840
  };
498
841
  export const getHomeUrl = () => {
499
842
  return `${window.location.origin}/`;
500
843
  };
501
844
  export const authIsMainRedirect = () => {
502
845
  // Even with main redirect, we want to use it only for the first login (so it doesn't wipe out any state or the reload)
503
- return !authNoRedirect() && !usePopupForRestOfSession;
846
+ return !gAuthMgr.noInitialRedirect && !gAuthMgr.usePopupForRestOfSession;
504
847
  };
505
- // Passive update where just session storage is updated so can be used on a window refresh
506
- export const authTokenUpdated = (tokenInfo) => {
507
- sessionStorage.setItem("rsdk_TI", JSON.stringify(tokenInfo));
848
+ export const sdkIsLoggedIn = () => {
849
+ return gAuthMgr.isLoggedIn;
508
850
  };
509
851
  export const logout = () => {
510
- sessionStorage.removeItem('rsdk_portalName');
511
- return new Promise((resolve) => {
512
- const fnClearAndResolve = () => {
513
- clearAuthMgr();
514
- const event = new Event('SdkLoggedOut');
515
- document.dispatchEvent(event);
516
- resolve();
517
- };
518
- if (gbCustomAuth) {
519
- sessionStorage.removeItem("rsdk_AH");
520
- fnClearAndResolve();
521
- return;
522
- }
523
- const tokenInfo = getCurrentTokens();
524
- if (tokenInfo && tokenInfo.access_token) {
525
- if (window.PCore) {
526
- window.PCore.getAuthUtils().revokeTokens().then(() => {
527
- fnClearAndResolve();
528
- }).catch(err => {
529
- // eslint-disable-next-line no-console
530
- console.log("Error:", err?.message);
531
- });
532
- }
533
- else {
534
- getAuthMgr(false).then((aMgr) => {
535
- aMgr.revokeTokens(tokenInfo.access_token, tokenInfo.refresh_token)
536
- .then(() => {
537
- // Go to finally
538
- })
539
- .finally(() => {
540
- fnClearAndResolve();
541
- });
542
- });
543
- }
544
- }
545
- else {
546
- fnClearAndResolve();
547
- }
548
- });
549
- };
550
- // Callback routine for custom event to ask for updated tokens
551
- export const authUpdateTokens = (token) => {
552
- processTokenOnLogin(token);
553
- };
554
- // Initiate a full OAuth re-authorization (any refresh token has also expired).
555
- export const authFullReauth = () => {
556
- const bHandleHere = true; // Other alternative is to raise an event and have someone else handle it
557
- if (bHandleHere) {
558
- // Don't want to do a full clear of authMgr as will loose sessionIndex. Rather just clear the tokens
559
- clearAuthMgr(true);
560
- login(true);
561
- }
562
- else {
563
- // Fire the SdkFullReauth event to indicate a new token is needed (PCore.getAuthUtils.setTokens method
564
- // should be used to communicate the new token to Constellation JS Engine.
565
- const event = new CustomEvent('SdkFullReauth', { detail: authUpdateTokens });
566
- document.dispatchEvent(event);
567
- }
852
+ return gAuthMgr.logout();
568
853
  };
569
854
  // Set the custom authorization header for the SDK (and Constellation JS Engine) to
570
855
  // utilize for every DX API request
571
856
  export const sdkSetAuthHeader = (authHeader) => {
572
- // set this within session storage so it survives a browser reload
573
- if (authHeader) {
574
- sessionStorage.setItem("rsdk_AH", authHeader);
575
- // setAuthorizationHeader method not available til 8.8 so do safety check
576
- if (window.PCore?.getAuthUtils().setAuthorizationHeader) {
577
- window.PCore.getAuthUtils().setAuthorizationHeader(authHeader);
578
- }
579
- }
580
- else {
581
- sessionStorage.removeItem("rsdk_AH");
582
- }
583
- gbCustomAuth = true;
857
+ gAuthMgr.bCustomAuth = !!authHeader;
858
+ // Use setter to set this securely
859
+ gAuthMgr.authHeader = authHeader;
584
860
  };
585
- // Initiate a custom re-authorization.
586
- export const authCustomReauth = () => {
587
- // Fire the SdkCustomReauth event to indicate a new authHeader is needed. Event listener should invoke sdkSetAuthHeader
588
- // to communicate the new token to sdk (and Constellation JS Engine)
589
- const event = new CustomEvent('SdkCustomReauth', { detail: sdkSetAuthHeader });
590
- document.dispatchEvent(event);
861
+ export const getAvailablePortals = async () => {
862
+ return gAuthMgr.getAvailablePortals();
591
863
  };
592
864
  //# sourceMappingURL=authManager.js.map