@pega/react-sdk-components 8.8.21 → 8.23.11-debug

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 (490) hide show
  1. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.d.ts +10 -7
  2. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.d.ts.map +1 -1
  3. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.js +7 -0
  4. package/lib/components/designSystemExtension/AlertBanner/AlertBanner.js.map +1 -1
  5. package/lib/components/designSystemExtension/Banner/Banner.d.ts +1 -15
  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 +9 -6
  9. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.d.ts.map +1 -1
  10. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.js +7 -3
  11. package/lib/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.js.map +1 -1
  12. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.d.ts +10 -4
  13. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.d.ts.map +1 -1
  14. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.js +8 -1
  15. package/lib/components/designSystemExtension/DetailsFields/DetailsFields.js.map +1 -1
  16. package/lib/components/designSystemExtension/FieldGroup/FieldGroup.d.ts +2 -6
  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 +2 -7
  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 +2 -7
  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 +7 -17
  29. package/lib/components/designSystemExtension/Operator/Operator.d.ts.map +1 -1
  30. package/lib/components/designSystemExtension/Operator/Operator.js +6 -1
  31. package/lib/components/designSystemExtension/Operator/Operator.js.map +1 -1
  32. package/lib/components/designSystemExtension/Pulse/Pulse.d.ts +1 -5
  33. package/lib/components/designSystemExtension/Pulse/Pulse.d.ts.map +1 -1
  34. package/lib/components/designSystemExtension/Pulse/Pulse.js +6 -3
  35. package/lib/components/designSystemExtension/Pulse/Pulse.js.map +1 -1
  36. package/lib/components/designSystemExtension/WssQuickCreate/WssQuickCreate.d.ts +1 -6
  37. package/lib/components/designSystemExtension/WssQuickCreate/WssQuickCreate.d.ts.map +1 -1
  38. package/lib/components/designSystemExtension/WssQuickCreate/WssQuickCreate.js.map +1 -1
  39. package/lib/components/field/AutoComplete/AutoComplete.d.ts +1 -15
  40. package/lib/components/field/AutoComplete/AutoComplete.d.ts.map +1 -1
  41. package/lib/components/field/AutoComplete/AutoComplete.js +15 -17
  42. package/lib/components/field/AutoComplete/AutoComplete.js.map +1 -1
  43. package/lib/components/field/CancelAlert/CancelAlert.d.ts +2 -7
  44. package/lib/components/field/CancelAlert/CancelAlert.d.ts.map +1 -1
  45. package/lib/components/field/CancelAlert/CancelAlert.js +3 -3
  46. package/lib/components/field/CancelAlert/CancelAlert.js.map +1 -1
  47. package/lib/components/field/Checkbox/Checkbox.d.ts +1 -19
  48. package/lib/components/field/Checkbox/Checkbox.d.ts.map +1 -1
  49. package/lib/components/field/Checkbox/Checkbox.js +8 -10
  50. package/lib/components/field/Checkbox/Checkbox.js.map +1 -1
  51. package/lib/components/field/Currency/Currency.d.ts +1 -6
  52. package/lib/components/field/Currency/Currency.d.ts.map +1 -1
  53. package/lib/components/field/Currency/Currency.js +11 -11
  54. package/lib/components/field/Currency/Currency.js.map +1 -1
  55. package/lib/components/field/Currency/currency-utils.d.ts.map +1 -1
  56. package/lib/components/field/Currency/currency-utils.js +1 -1
  57. package/lib/components/field/Currency/currency-utils.js.map +1 -1
  58. package/lib/components/field/Date/Date.d.ts +1 -5
  59. package/lib/components/field/Date/Date.d.ts.map +1 -1
  60. package/lib/components/field/Date/Date.js +6 -8
  61. package/lib/components/field/Date/Date.js.map +1 -1
  62. package/lib/components/field/DateTime/DateTime.d.ts +1 -5
  63. package/lib/components/field/DateTime/DateTime.d.ts.map +1 -1
  64. package/lib/components/field/DateTime/DateTime.js +8 -14
  65. package/lib/components/field/DateTime/DateTime.js.map +1 -1
  66. package/lib/components/field/Decimal/Decimal.d.ts +1 -8
  67. package/lib/components/field/Decimal/Decimal.d.ts.map +1 -1
  68. package/lib/components/field/Decimal/Decimal.js +9 -10
  69. package/lib/components/field/Decimal/Decimal.js.map +1 -1
  70. package/lib/components/field/Dropdown/Dropdown.d.ts +1 -10
  71. package/lib/components/field/Dropdown/Dropdown.d.ts.map +1 -1
  72. package/lib/components/field/Dropdown/Dropdown.js +9 -12
  73. package/lib/components/field/Dropdown/Dropdown.js.map +1 -1
  74. package/lib/components/field/Email/Email.d.ts +1 -5
  75. package/lib/components/field/Email/Email.d.ts.map +1 -1
  76. package/lib/components/field/Email/Email.js +5 -7
  77. package/lib/components/field/Email/Email.js.map +1 -1
  78. package/lib/components/field/Integer/Integer.d.ts +1 -5
  79. package/lib/components/field/Integer/Integer.d.ts.map +1 -1
  80. package/lib/components/field/Integer/Integer.js +4 -6
  81. package/lib/components/field/Integer/Integer.js.map +1 -1
  82. package/lib/components/field/Percentage/Percentage.d.ts +1 -5
  83. package/lib/components/field/Percentage/Percentage.d.ts.map +1 -1
  84. package/lib/components/field/Percentage/Percentage.js +4 -6
  85. package/lib/components/field/Percentage/Percentage.js.map +1 -1
  86. package/lib/components/field/Phone/Phone.d.ts +1 -5
  87. package/lib/components/field/Phone/Phone.d.ts.map +1 -1
  88. package/lib/components/field/Phone/Phone.js +6 -8
  89. package/lib/components/field/Phone/Phone.js.map +1 -1
  90. package/lib/components/field/RadioButtons/RadioButtons.d.ts +1 -7
  91. package/lib/components/field/RadioButtons/RadioButtons.d.ts.map +1 -1
  92. package/lib/components/field/RadioButtons/RadioButtons.js +12 -12
  93. package/lib/components/field/RadioButtons/RadioButtons.js.map +1 -1
  94. package/lib/components/field/SemanticLink/SemanticLink.d.ts +9 -5
  95. package/lib/components/field/SemanticLink/SemanticLink.d.ts.map +1 -1
  96. package/lib/components/field/SemanticLink/SemanticLink.js +14 -10
  97. package/lib/components/field/SemanticLink/SemanticLink.js.map +1 -1
  98. package/lib/components/field/TextArea/TextArea.d.ts +1 -6
  99. package/lib/components/field/TextArea/TextArea.d.ts.map +1 -1
  100. package/lib/components/field/TextArea/TextArea.js +3 -5
  101. package/lib/components/field/TextArea/TextArea.js.map +1 -1
  102. package/lib/components/field/TextContent/TextContent.d.ts +1 -7
  103. package/lib/components/field/TextContent/TextContent.d.ts.map +1 -1
  104. package/lib/components/field/TextContent/TextContent.js.map +1 -1
  105. package/lib/components/field/TextInput/TextInput.d.ts +1 -6
  106. package/lib/components/field/TextInput/TextInput.d.ts.map +1 -1
  107. package/lib/components/field/TextInput/TextInput.js +4 -6
  108. package/lib/components/field/TextInput/TextInput.js.map +1 -1
  109. package/lib/components/field/Time/Time.d.ts +1 -5
  110. package/lib/components/field/Time/Time.d.ts.map +1 -1
  111. package/lib/components/field/Time/Time.js +8 -10
  112. package/lib/components/field/Time/Time.js.map +1 -1
  113. package/lib/components/field/URL/URL.d.ts +1 -5
  114. package/lib/components/field/URL/URL.d.ts.map +1 -1
  115. package/lib/components/field/URL/URL.js +4 -6
  116. package/lib/components/field/URL/URL.js.map +1 -1
  117. package/lib/components/field/UserReference/UserReference.d.ts +40 -19
  118. package/lib/components/field/UserReference/UserReference.d.ts.map +1 -1
  119. package/lib/components/field/UserReference/UserReference.js +45 -16
  120. package/lib/components/field/UserReference/UserReference.js.map +1 -1
  121. package/lib/components/helpers/attachmentHelpers.d.ts +3 -3
  122. package/lib/components/helpers/attachmentHelpers.d.ts.map +1 -1
  123. package/lib/components/helpers/attachmentHelpers.js.map +1 -1
  124. package/lib/components/helpers/auth.d.ts +6 -8
  125. package/lib/components/helpers/auth.d.ts.map +1 -1
  126. package/lib/components/helpers/auth.js +335 -642
  127. package/lib/components/helpers/auth.js.map +1 -1
  128. package/lib/components/helpers/authManager.d.ts +17 -20
  129. package/lib/components/helpers/authManager.d.ts.map +1 -1
  130. package/lib/components/helpers/authManager.js +439 -711
  131. package/lib/components/helpers/authManager.js.map +1 -1
  132. package/lib/components/helpers/case-utils.d.ts.map +1 -1
  133. package/lib/components/helpers/case-utils.js +4 -5
  134. package/lib/components/helpers/case-utils.js.map +1 -1
  135. package/lib/components/helpers/common-utils.d.ts +1 -1
  136. package/lib/components/helpers/common-utils.js.map +1 -1
  137. package/lib/components/helpers/config_access.d.ts.map +1 -1
  138. package/lib/components/helpers/config_access.js +63 -0
  139. package/lib/components/helpers/config_access.js.map +1 -1
  140. package/lib/components/helpers/date-format-utils.d.ts +6 -1
  141. package/lib/components/helpers/date-format-utils.d.ts.map +1 -1
  142. package/lib/components/helpers/date-format-utils.js.map +1 -1
  143. package/lib/components/helpers/event-utils.d.ts +1 -1
  144. package/lib/components/helpers/event-utils.d.ts.map +1 -1
  145. package/lib/components/helpers/event-utils.js.map +1 -1
  146. package/lib/components/helpers/formatters/Currency.d.ts +6 -6
  147. package/lib/components/helpers/formatters/Currency.js +2 -2
  148. package/lib/components/helpers/formatters/Currency.js.map +1 -1
  149. package/lib/components/helpers/formatters/CurrencyMap.d.ts +320 -69
  150. package/lib/components/helpers/formatters/CurrencyMap.d.ts.map +1 -1
  151. package/lib/components/helpers/formatters/CurrencyMap.js.map +1 -1
  152. package/lib/components/helpers/formatters/Date.d.ts +4 -4
  153. package/lib/components/helpers/formatters/Date.js.map +1 -1
  154. package/lib/components/helpers/formatters/common.d.ts +1 -1
  155. package/lib/components/helpers/formatters/common.d.ts.map +1 -1
  156. package/lib/components/helpers/formatters/common.js.map +1 -1
  157. package/lib/components/helpers/formatters/index.d.ts +11 -11
  158. package/lib/components/helpers/formatters/index.d.ts.map +1 -1
  159. package/lib/components/helpers/formatters/index.js.map +1 -1
  160. package/lib/components/helpers/simpleTableHelpers.d.ts +1 -3
  161. package/lib/components/helpers/simpleTableHelpers.d.ts.map +1 -1
  162. package/lib/components/helpers/simpleTableHelpers.js +3 -5
  163. package/lib/components/helpers/simpleTableHelpers.js.map +1 -1
  164. package/lib/components/helpers/state-utils.d.ts.map +1 -1
  165. package/lib/components/helpers/state-utils.js.map +1 -1
  166. package/lib/components/helpers/template-utils.d.ts +3 -7
  167. package/lib/components/helpers/template-utils.d.ts.map +1 -1
  168. package/lib/components/helpers/template-utils.js +0 -1
  169. package/lib/components/helpers/template-utils.js.map +1 -1
  170. package/lib/components/helpers/versionHelpers.d.ts +0 -6
  171. package/lib/components/helpers/versionHelpers.d.ts.map +1 -1
  172. package/lib/components/helpers/versionHelpers.js +0 -6
  173. package/lib/components/helpers/versionHelpers.js.map +1 -1
  174. package/lib/components/infra/ActionButtons/ActionButtons.d.ts +13 -6
  175. package/lib/components/infra/ActionButtons/ActionButtons.d.ts.map +1 -1
  176. package/lib/components/infra/ActionButtons/ActionButtons.js +13 -1
  177. package/lib/components/infra/ActionButtons/ActionButtons.js.map +1 -1
  178. package/lib/components/infra/Assignment/Assignment.d.ts +15 -9
  179. package/lib/components/infra/Assignment/Assignment.d.ts.map +1 -1
  180. package/lib/components/infra/Assignment/Assignment.js +21 -8
  181. package/lib/components/infra/Assignment/Assignment.js.map +1 -1
  182. package/lib/components/infra/AssignmentCard/AssignmentCard.d.ts +14 -8
  183. package/lib/components/infra/AssignmentCard/AssignmentCard.d.ts.map +1 -1
  184. package/lib/components/infra/AssignmentCard/AssignmentCard.js +16 -3
  185. package/lib/components/infra/AssignmentCard/AssignmentCard.js.map +1 -1
  186. package/lib/components/infra/Containers/FlowContainer/FlowContainer.d.ts +21 -1
  187. package/lib/components/infra/Containers/FlowContainer/FlowContainer.d.ts.map +1 -1
  188. package/lib/components/infra/Containers/FlowContainer/FlowContainer.js +48 -41
  189. package/lib/components/infra/Containers/FlowContainer/FlowContainer.js.map +1 -1
  190. package/lib/components/infra/Containers/FlowContainer/helpers.d.ts.map +1 -1
  191. package/lib/components/infra/Containers/FlowContainer/helpers.js.map +1 -1
  192. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.d.ts +17 -8
  193. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.d.ts.map +1 -1
  194. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.js +17 -6
  195. package/lib/components/infra/Containers/ModalViewContainer/ModalViewContainer.js.map +1 -1
  196. package/lib/components/infra/Containers/ViewContainer/ViewContainer.d.ts +22 -9
  197. package/lib/components/infra/Containers/ViewContainer/ViewContainer.d.ts.map +1 -1
  198. package/lib/components/infra/Containers/ViewContainer/ViewContainer.js +20 -3
  199. package/lib/components/infra/Containers/ViewContainer/ViewContainer.js.map +1 -1
  200. package/lib/components/infra/DashboardFilter/DashboardFilter.d.ts +19 -9
  201. package/lib/components/infra/DashboardFilter/DashboardFilter.d.ts.map +1 -1
  202. package/lib/components/infra/DashboardFilter/DashboardFilter.js +16 -2
  203. package/lib/components/infra/DashboardFilter/DashboardFilter.js.map +1 -1
  204. package/lib/components/infra/DashboardFilter/filterUtils.js +1 -1
  205. package/lib/components/infra/DashboardFilter/filterUtils.js.map +1 -1
  206. package/lib/components/infra/DeferLoad/DeferLoad.d.ts +14 -1
  207. package/lib/components/infra/DeferLoad/DeferLoad.d.ts.map +1 -1
  208. package/lib/components/infra/DeferLoad/DeferLoad.js +15 -13
  209. package/lib/components/infra/DeferLoad/DeferLoad.js.map +1 -1
  210. package/lib/components/infra/ErrorBoundary/ErrorBoundary.d.ts +12 -5
  211. package/lib/components/infra/ErrorBoundary/ErrorBoundary.d.ts.map +1 -1
  212. package/lib/components/infra/ErrorBoundary/ErrorBoundary.js +12 -2
  213. package/lib/components/infra/ErrorBoundary/ErrorBoundary.js.map +1 -1
  214. package/lib/components/infra/MultiStep/MultiStep.d.ts +17 -11
  215. package/lib/components/infra/MultiStep/MultiStep.d.ts.map +1 -1
  216. package/lib/components/infra/MultiStep/MultiStep.js +18 -4
  217. package/lib/components/infra/MultiStep/MultiStep.js.map +1 -1
  218. package/lib/components/infra/NavBar/NavBar.d.ts +16 -8
  219. package/lib/components/infra/NavBar/NavBar.d.ts.map +1 -1
  220. package/lib/components/infra/NavBar/NavBar.js +16 -3
  221. package/lib/components/infra/NavBar/NavBar.js.map +1 -1
  222. package/lib/components/infra/Reference/Reference.d.ts +17 -8
  223. package/lib/components/infra/Reference/Reference.d.ts.map +1 -1
  224. package/lib/components/infra/Reference/Reference.js +15 -1
  225. package/lib/components/infra/Reference/Reference.js.map +1 -1
  226. package/lib/components/infra/Region/Region.d.ts +7 -4
  227. package/lib/components/infra/Region/Region.d.ts.map +1 -1
  228. package/lib/components/infra/Region/Region.js +4 -0
  229. package/lib/components/infra/Region/Region.js.map +1 -1
  230. package/lib/components/infra/RootContainer/RootContainer.d.ts +21 -1
  231. package/lib/components/infra/RootContainer/RootContainer.d.ts.map +1 -1
  232. package/lib/components/infra/RootContainer/RootContainer.js +21 -4
  233. package/lib/components/infra/RootContainer/RootContainer.js.map +1 -1
  234. package/lib/components/infra/Stages/Stages.d.ts +8 -5
  235. package/lib/components/infra/Stages/Stages.d.ts.map +1 -1
  236. package/lib/components/infra/Stages/Stages.js +6 -1
  237. package/lib/components/infra/Stages/Stages.js.map +1 -1
  238. package/lib/components/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.d.ts.map +1 -1
  239. package/lib/components/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.js.map +1 -1
  240. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.d.ts +10 -4
  241. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.d.ts.map +1 -1
  242. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.js +9 -4
  243. package/lib/components/infra/VerticalTabs/VerticalTabs/VerticalTabs.js.map +1 -1
  244. package/lib/components/infra/View/View.d.ts +16 -13
  245. package/lib/components/infra/View/View.d.ts.map +1 -1
  246. package/lib/components/infra/View/View.js +20 -2
  247. package/lib/components/infra/View/View.js.map +1 -1
  248. package/lib/components/template/AppShell/AppShell.d.ts +15 -20
  249. package/lib/components/template/AppShell/AppShell.d.ts.map +1 -1
  250. package/lib/components/template/AppShell/AppShell.js +22 -10
  251. package/lib/components/template/AppShell/AppShell.js.map +1 -1
  252. package/lib/components/template/BannerPage/BannerPage.d.ts +23 -11
  253. package/lib/components/template/BannerPage/BannerPage.d.ts.map +1 -1
  254. package/lib/components/template/BannerPage/BannerPage.js +22 -4
  255. package/lib/components/template/BannerPage/BannerPage.js.map +1 -1
  256. package/lib/components/template/CaseSummary/CaseSummary.d.ts +7 -5
  257. package/lib/components/template/CaseSummary/CaseSummary.d.ts.map +1 -1
  258. package/lib/components/template/CaseSummary/CaseSummary.js +6 -6
  259. package/lib/components/template/CaseSummary/CaseSummary.js.map +1 -1
  260. package/lib/components/template/CaseView/CaseView.d.ts +22 -10
  261. package/lib/components/template/CaseView/CaseView.d.ts.map +1 -1
  262. package/lib/components/template/CaseView/CaseView.js +21 -8
  263. package/lib/components/template/CaseView/CaseView.js.map +1 -1
  264. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.d.ts +15 -8
  265. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.d.ts.map +1 -1
  266. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.js +12 -0
  267. package/lib/components/template/CaseViewActionsMenu/CaseViewActionsMenu.js.map +1 -1
  268. package/lib/components/template/Confirmation/Confirmation.d.ts +16 -10
  269. package/lib/components/template/Confirmation/Confirmation.d.ts.map +1 -1
  270. package/lib/components/template/Confirmation/Confirmation.js +23 -12
  271. package/lib/components/template/Confirmation/Confirmation.js.map +1 -1
  272. package/lib/components/template/DataReference/DataReference.d.ts +31 -1
  273. package/lib/components/template/DataReference/DataReference.d.ts.map +1 -1
  274. package/lib/components/template/DataReference/DataReference.js +48 -41
  275. package/lib/components/template/DataReference/DataReference.js.map +1 -1
  276. package/lib/components/template/DefaultForm/DefaultForm.d.ts +11 -1
  277. package/lib/components/template/DefaultForm/DefaultForm.d.ts.map +1 -1
  278. package/lib/components/template/DefaultForm/DefaultForm.js +10 -9
  279. package/lib/components/template/DefaultForm/DefaultForm.js.map +1 -1
  280. package/lib/components/template/Details/Details/Details.d.ts +16 -1
  281. package/lib/components/template/Details/Details/Details.d.ts.map +1 -1
  282. package/lib/components/template/Details/Details/Details.js +15 -10
  283. package/lib/components/template/Details/Details/Details.js.map +1 -1
  284. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.d.ts +15 -7
  285. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.d.ts.map +1 -1
  286. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.js +13 -1
  287. package/lib/components/template/Details/DetailsSubTabs/DetailsSubTabs.js.map +1 -1
  288. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.d.ts +16 -1
  289. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.d.ts.map +1 -1
  290. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.js +16 -14
  291. package/lib/components/template/Details/DetailsThreeColumn/DetailsThreeColumn.js.map +1 -1
  292. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.d.ts +16 -1
  293. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.d.ts.map +1 -1
  294. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.js +16 -14
  295. package/lib/components/template/Details/DetailsTwoColumn/DetailsTwoColumn.js.map +1 -1
  296. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.d.ts +19 -12
  297. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.d.ts.map +1 -1
  298. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.js +21 -7
  299. package/lib/components/template/FieldGroupTemplate/FieldGroupTemplate.js.map +1 -1
  300. package/lib/components/template/InlineDashboard/InlineDashboard.d.ts +7 -7
  301. package/lib/components/template/InlineDashboard/InlineDashboard.d.ts.map +1 -1
  302. package/lib/components/template/InlineDashboard/InlineDashboard.js +5 -0
  303. package/lib/components/template/InlineDashboard/InlineDashboard.js.map +1 -1
  304. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.d.ts +15 -8
  305. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.d.ts.map +1 -1
  306. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.js +14 -5
  307. package/lib/components/template/InlineDashboardPage/InlineDashboardPage.js.map +1 -1
  308. package/lib/components/template/ListPage/ListPage.d.ts +13 -5
  309. package/lib/components/template/ListPage/ListPage.d.ts.map +1 -1
  310. package/lib/components/template/ListPage/ListPage.js +10 -6
  311. package/lib/components/template/ListPage/ListPage.js.map +1 -1
  312. package/lib/components/template/ListView/ListView.d.ts +9 -1
  313. package/lib/components/template/ListView/ListView.d.ts.map +1 -1
  314. package/lib/components/template/ListView/ListView.js +123 -127
  315. package/lib/components/template/ListView/ListView.js.map +1 -1
  316. package/lib/components/template/ListView/utils.d.ts +0 -44
  317. package/lib/components/template/ListView/utils.d.ts.map +1 -1
  318. package/lib/components/template/ListView/utils.js +1 -142
  319. package/lib/components/template/ListView/utils.js.map +1 -1
  320. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.d.ts +13 -9
  321. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.d.ts.map +1 -1
  322. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.js +13 -2
  323. package/lib/components/template/MultiReferenceReadOnly/MultiReferenceReadOnly.js.map +1 -1
  324. package/lib/components/template/NarrowWide/NarrowWide/NarrowWide.d.ts +1 -10
  325. package/lib/components/template/NarrowWide/NarrowWide/NarrowWide.d.ts.map +1 -1
  326. package/lib/components/template/NarrowWide/NarrowWide/NarrowWide.js.map +1 -1
  327. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.d.ts +16 -1
  328. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.d.ts.map +1 -1
  329. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.js +16 -14
  330. package/lib/components/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.js.map +1 -1
  331. package/lib/components/template/NarrowWide/NarrowWideForm/NarrowWideForm.d.ts +1 -5
  332. package/lib/components/template/NarrowWide/NarrowWideForm/NarrowWideForm.d.ts.map +1 -1
  333. package/lib/components/template/NarrowWide/NarrowWideForm/NarrowWideForm.js.map +1 -1
  334. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.d.ts +14 -7
  335. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.d.ts.map +1 -1
  336. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.js +13 -4
  337. package/lib/components/template/NarrowWide/NarrowWidePage/NarrowWidePage.js.map +1 -1
  338. package/lib/components/template/OneColumn/OneColumn/OneColumn.d.ts +7 -4
  339. package/lib/components/template/OneColumn/OneColumn/OneColumn.d.ts.map +1 -1
  340. package/lib/components/template/OneColumn/OneColumn/OneColumn.js +5 -0
  341. package/lib/components/template/OneColumn/OneColumn/OneColumn.js.map +1 -1
  342. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.d.ts +8 -4
  343. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.d.ts.map +1 -1
  344. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.js +6 -3
  345. package/lib/components/template/OneColumn/OneColumnPage/OneColumnPage.js.map +1 -1
  346. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.d.ts +7 -4
  347. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.d.ts.map +1 -1
  348. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.js +5 -0
  349. package/lib/components/template/OneColumn/OneColumnTab/OneColumnTab.js.map +1 -1
  350. package/lib/components/template/PromotedFilters/PromotedFilters.d.ts +15 -1
  351. package/lib/components/template/PromotedFilters/PromotedFilters.d.ts.map +1 -1
  352. package/lib/components/template/PromotedFilters/PromotedFilters.js +11 -15
  353. package/lib/components/template/PromotedFilters/PromotedFilters.js.map +1 -1
  354. package/lib/components/template/SimpleTable/SimpleTable/SimpleTable.d.ts.map +1 -1
  355. package/lib/components/template/SimpleTable/SimpleTable/SimpleTable.js +5 -57
  356. package/lib/components/template/SimpleTable/SimpleTable/SimpleTable.js.map +1 -1
  357. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.d.ts +1 -18
  358. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.d.ts.map +1 -1
  359. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.js +2 -2
  360. package/lib/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.js.map +1 -1
  361. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.d.ts +29 -1
  362. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.d.ts.map +1 -1
  363. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.js +28 -22
  364. package/lib/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.js.map +1 -1
  365. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.d.ts +26 -14
  366. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.d.ts.map +1 -1
  367. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.js +26 -5
  368. package/lib/components/template/SingleReferenceReadOnly/SingleReferenceReadOnly.js.map +1 -1
  369. package/lib/components/template/SubTabs/SubTabs.d.ts +10 -4
  370. package/lib/components/template/SubTabs/SubTabs.d.ts.map +1 -1
  371. package/lib/components/template/SubTabs/SubTabs.js +8 -1
  372. package/lib/components/template/SubTabs/SubTabs.js.map +1 -1
  373. package/lib/components/template/SubTabs/tabUtils.d.ts.map +1 -1
  374. package/lib/components/template/SubTabs/tabUtils.js.map +1 -1
  375. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.d.ts +11 -5
  376. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.d.ts.map +1 -1
  377. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.js +12 -1
  378. package/lib/components/template/TwoColumn/TwoColumn/TwoColumn.js.map +1 -1
  379. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.d.ts +8 -4
  380. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.d.ts.map +1 -1
  381. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.js +6 -3
  382. package/lib/components/template/TwoColumn/TwoColumnPage/TwoColumnPage.js.map +1 -1
  383. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.d.ts +11 -5
  384. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.d.ts.map +1 -1
  385. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.js +9 -1
  386. package/lib/components/template/TwoColumn/TwoColumnTab/TwoColumnTab.js.map +1 -1
  387. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.d.ts +1 -10
  388. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.d.ts.map +1 -1
  389. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.js +1 -1
  390. package/lib/components/template/WideNarrow/WideNarrow/WideNarrow.js.map +1 -1
  391. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.d.ts +16 -1
  392. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.d.ts.map +1 -1
  393. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.js +23 -31
  394. package/lib/components/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.js.map +1 -1
  395. package/lib/components/template/WideNarrow/WideNarrowForm/WideNarrowForm.d.ts +1 -5
  396. package/lib/components/template/WideNarrow/WideNarrowForm/WideNarrowForm.d.ts.map +1 -1
  397. package/lib/components/template/WideNarrow/WideNarrowForm/WideNarrowForm.js.map +1 -1
  398. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.d.ts +14 -7
  399. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.d.ts.map +1 -1
  400. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.js +14 -4
  401. package/lib/components/template/WideNarrow/WideNarrowPage/WideNarrowPage.js.map +1 -1
  402. package/lib/components/template/WssNavBar/WssNavBar.d.ts +1 -17
  403. package/lib/components/template/WssNavBar/WssNavBar.d.ts.map +1 -1
  404. package/lib/components/template/WssNavBar/WssNavBar.js.map +1 -1
  405. package/lib/components/widget/AppAnnouncement/AppAnnouncement.d.ts +17 -8
  406. package/lib/components/widget/AppAnnouncement/AppAnnouncement.d.ts.map +1 -1
  407. package/lib/components/widget/AppAnnouncement/AppAnnouncement.js +19 -4
  408. package/lib/components/widget/AppAnnouncement/AppAnnouncement.js.map +1 -1
  409. package/lib/components/widget/Attachment/Attachment.d.ts.map +1 -1
  410. package/lib/components/widget/Attachment/Attachment.js +16 -24
  411. package/lib/components/widget/Attachment/Attachment.js.map +1 -1
  412. package/lib/components/widget/CaseHistory/CaseHistory.d.ts +7 -4
  413. package/lib/components/widget/CaseHistory/CaseHistory.d.ts.map +1 -1
  414. package/lib/components/widget/CaseHistory/CaseHistory.js +8 -4
  415. package/lib/components/widget/CaseHistory/CaseHistory.js.map +1 -1
  416. package/lib/components/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.d.ts +1 -8
  417. package/lib/components/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.d.ts.map +1 -1
  418. package/lib/components/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.js.map +1 -1
  419. package/lib/components/widget/FileUtility/FileUtility/FileUtility.d.ts +1 -5
  420. package/lib/components/widget/FileUtility/FileUtility/FileUtility.d.ts.map +1 -1
  421. package/lib/components/widget/FileUtility/FileUtility/FileUtility.js +21 -31
  422. package/lib/components/widget/FileUtility/FileUtility/FileUtility.js.map +1 -1
  423. package/lib/components/widget/Followers/Followers.d.ts +5 -4
  424. package/lib/components/widget/Followers/Followers.d.ts.map +1 -1
  425. package/lib/components/widget/Followers/Followers.js +10 -3
  426. package/lib/components/widget/Followers/Followers.js.map +1 -1
  427. package/lib/components/widget/QuickCreate/QuickCreate.d.ts.map +1 -1
  428. package/lib/components/widget/QuickCreate/QuickCreate.js +2 -10
  429. package/lib/components/widget/QuickCreate/QuickCreate.js.map +1 -1
  430. package/lib/components/widget/SummaryItem/SummaryItem.d.ts +1 -7
  431. package/lib/components/widget/SummaryItem/SummaryItem.d.ts.map +1 -1
  432. package/lib/components/widget/SummaryItem/SummaryItem.js.map +1 -1
  433. package/lib/components/widget/SummaryList/SummaryList.d.ts +1 -7
  434. package/lib/components/widget/SummaryList/SummaryList.d.ts.map +1 -1
  435. package/lib/components/widget/SummaryList/SummaryList.js +2 -5
  436. package/lib/components/widget/SummaryList/SummaryList.js.map +1 -1
  437. package/lib/components/widget/ToDo/ToDo.d.ts +27 -13
  438. package/lib/components/widget/ToDo/ToDo.d.ts.map +1 -1
  439. package/lib/components/widget/ToDo/ToDo.js +64 -28
  440. package/lib/components/widget/ToDo/ToDo.js.map +1 -1
  441. package/lib/doc/KeyReleaseUpdates.md +0 -21
  442. package/lib/index.d.ts +0 -1
  443. package/lib/index.d.ts.map +1 -1
  444. package/lib/index.js +1 -2
  445. package/lib/index.js.map +1 -1
  446. package/lib/sdk-pega-component-map.d.ts +1 -15
  447. package/lib/sdk-pega-component-map.js +1 -15
  448. package/lib/sdk-pega-component-map.js.map +1 -1
  449. package/package.json +1 -1
  450. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.d.ts +0 -19
  451. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.d.ts.map +0 -1
  452. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.js +0 -77
  453. package/lib/components/designSystemExtension/RichTextEditor/RichTextEditor.js.map +0 -1
  454. package/lib/components/designSystemExtension/RichTextEditor/index.d.ts +0 -2
  455. package/lib/components/designSystemExtension/RichTextEditor/index.d.ts.map +0 -1
  456. package/lib/components/designSystemExtension/RichTextEditor/index.js +0 -2
  457. package/lib/components/designSystemExtension/RichTextEditor/index.js.map +0 -1
  458. package/lib/components/field/RichText/RichText.d.ts +0 -7
  459. package/lib/components/field/RichText/RichText.d.ts.map +0 -1
  460. package/lib/components/field/RichText/RichText.js +0 -51
  461. package/lib/components/field/RichText/RichText.js.map +0 -1
  462. package/lib/components/field/RichText/index.d.ts +0 -2
  463. package/lib/components/field/RichText/index.d.ts.map +0 -1
  464. package/lib/components/field/RichText/index.js +0 -2
  465. package/lib/components/field/RichText/index.js.map +0 -1
  466. package/lib/components/field/ScalarList/ScalarList.d.ts +0 -13
  467. package/lib/components/field/ScalarList/ScalarList.d.ts.map +0 -1
  468. package/lib/components/field/ScalarList/ScalarList.js +0 -34
  469. package/lib/components/field/ScalarList/ScalarList.js.map +0 -1
  470. package/lib/components/field/ScalarList/index.d.ts +0 -2
  471. package/lib/components/field/ScalarList/index.d.ts.map +0 -1
  472. package/lib/components/field/ScalarList/index.js +0 -2
  473. package/lib/components/field/ScalarList/index.js.map +0 -1
  474. package/lib/hooks/index.d.ts +0 -4
  475. package/lib/hooks/index.d.ts.map +0 -1
  476. package/lib/hooks/index.js +0 -4
  477. package/lib/hooks/index.js.map +0 -1
  478. package/lib/hooks/useAfterInitialEffect.d.ts +0 -9
  479. package/lib/hooks/useAfterInitialEffect.d.ts.map +0 -1
  480. package/lib/hooks/useAfterInitialEffect.js +0 -16
  481. package/lib/hooks/useAfterInitialEffect.js.map +0 -1
  482. package/lib/hooks/useConsolidatedRef.d.ts +0 -9
  483. package/lib/hooks/useConsolidatedRef.d.ts.map +0 -1
  484. package/lib/hooks/useConsolidatedRef.js +0 -30
  485. package/lib/hooks/useConsolidatedRef.js.map +0 -1
  486. package/lib/hooks/useUID.d.ts +0 -8
  487. package/lib/hooks/useUID.d.ts.map +0 -1
  488. package/lib/hooks/useUID.js +0 -14
  489. package/lib/hooks/useUID.js.map +0 -1
  490. package/lib/types/PConnProps.d.ts +0 -42
@@ -3,64 +3,225 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  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");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- 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");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _PegaAuth_instances, _PegaAuth_config, _PegaAuth_dynState, _PegaAuth_reloadSS, _PegaAuth_reloadConfig, _PegaAuth_updateConfig, _PegaAuth_importSingleLib, _PegaAuth_importNodeLibs, _PegaAuth_buildAuthorizeUrl, _PegaAuth_authCodeStart, _PegaAuth_updateSessionIndex, _PegaAuth_sha256Hash, _PegaAuth_encode64, _PegaAuth_base64UrlSafeEncode, _PegaAuth_getRandomString, _PegaAuth_getCodeChallenge, _PegaAuth_getAgent;
6
+ var _PegaAuth_instances, _PegaAuth_updateConfig, _PegaAuth_buildAuthorizeUrl, _PegaAuth_sha256Hash, _PegaAuth_encode64, _PegaAuth_base64UrlSafeEncode, _PegaAuth_getCodeChallenge;
13
7
  class PegaAuth {
14
- // Current properties within dynState structure:
15
- // codeVerifier, state, sessionIndex, sessionIndexAttempts, acRedirectUri
16
- constructor(ssKeyConfig, ssKeyDynState) {
8
+ constructor(ssKeyConfig) {
17
9
  _PegaAuth_instances.add(this);
18
- // The properties within config structure are expected to be more static config values that are then
19
- // used to properly make various OAuth endpoint calls.
20
- _PegaAuth_config.set(this, null);
21
- // Any dynamic state is stored separately in its own structure. If a sessionStorage key is passed in
22
- // without a Dynamic State key.
23
- _PegaAuth_dynState.set(this, {});
24
- if (typeof ssKeyConfig === 'string') {
25
- this.ssKeyConfig = ssKeyConfig;
26
- this.ssKeyDynState = ssKeyDynState || `${ssKeyConfig}_DS`;
27
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_reloadConfig).call(this);
28
- }
29
- else {
30
- // object with config structure is passed in
31
- __classPrivateFieldSet(this, _PegaAuth_config, ssKeyConfig, "f");
32
- __classPrivateFieldSet(this, _PegaAuth_dynState, ssKeyDynState, "f");
33
- }
34
- this.urlencoded = 'application/x-www-form-urlencoded';
35
- this.isNode = typeof window === 'undefined';
36
- // For isNode path the below attributes are initialized on first method invocation
37
- if (!this.isNode) {
38
- this.crypto = window.crypto;
39
- this.subtle = window.crypto.subtle;
40
- }
41
- if (Object.keys(__classPrivateFieldGet(this, _PegaAuth_config, "f")).length > 0) {
42
- if (!__classPrivateFieldGet(this, _PegaAuth_config, "f").serverType) {
43
- __classPrivateFieldGet(this, _PegaAuth_config, "f").serverType = 'infinity';
10
+ this.ssKeyConfig = ssKeyConfig;
11
+ this.bEncodeSI = false;
12
+ this.reloadConfig();
13
+ }
14
+ reloadConfig() {
15
+ const peConfig = window.sessionStorage.getItem(this.ssKeyConfig);
16
+ let obj = {};
17
+ if (peConfig) {
18
+ try {
19
+ obj = JSON.parse(peConfig);
20
+ }
21
+ catch (e) {
22
+ try {
23
+ obj = JSON.parse(window.atob(peConfig));
24
+ }
25
+ catch (e2) {
26
+ obj = {};
27
+ }
44
28
  }
45
29
  }
46
- else {
47
- throw new Error('invalid config settings');
48
- }
30
+ this.config = peConfig ? obj : null;
49
31
  }
50
32
  async login() {
51
- if (this.isNode && !this.crypto) {
52
- // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
53
- await __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importNodeLibs).call(this);
54
- }
55
- const { grantType, noPKCE } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
56
- if (grantType && grantType !== 'authCode') {
57
- return this.getToken();
58
- }
59
- // Make sure browser in a secure context, else PKCE will fail
60
- if (!this.isNode && !noPKCE && !window.isSecureContext) {
61
- throw new Error(`Authorization code grant flow failed due to insecure browser context at ${window.location.origin}. Use localhost or https.`);
62
- }
63
- return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_authCodeStart).call(this);
33
+ const fnGetRedirectUriOrigin = () => {
34
+ const redirectUri = this.config.redirectUri;
35
+ const nRootOffset = redirectUri.indexOf("//");
36
+ const nFirstPathOffset = nRootOffset !== -1 ? redirectUri.indexOf("/", nRootOffset + 2) : -1;
37
+ return nFirstPathOffset !== -1 ? redirectUri.substring(0, nFirstPathOffset) : redirectUri;
38
+ };
39
+ const redirectOrigin = fnGetRedirectUriOrigin();
40
+ // eslint-disable-next-line no-restricted-globals
41
+ const state = window.btoa(location.origin);
42
+ return new Promise((resolve, reject) => {
43
+ __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_buildAuthorizeUrl).call(this, state).then((url) => {
44
+ let myWindow = null; // popup or iframe
45
+ let elIframe = null;
46
+ let elCloseBtn = null;
47
+ const iframeTimeout = this.config.silentTimeout !== undefined ? this.config.silentTimeout : 5000;
48
+ let bWinIframe = iframeTimeout > 0 && ((!!this.config.userIdentifier && !!this.config.password) || this.config.iframeLoginUI || this.config.authService !== "pega");
49
+ let tmrAuthComplete = null;
50
+ let checkWindowClosed = null;
51
+ const myWinOnLoad = () => {
52
+ try {
53
+ if (bWinIframe) {
54
+ elIframe.contentWindow.postMessage({ type: "PegaAuth" }, redirectOrigin);
55
+ // eslint-disable-next-line no-console
56
+ console.log("authjs(login): loaded a page in iFrame");
57
+ }
58
+ else {
59
+ myWindow.postMessage({ type: "PegaAuth" }, redirectOrigin);
60
+ }
61
+ }
62
+ catch (e) {
63
+ // eslint-disable-next-line no-console
64
+ console.log("authjs(login): Exception trying to postMessage on load");
65
+ }
66
+ };
67
+ const fnOpenPopup = () => {
68
+ myWindow = window.open(url, '_blank', 'width=700,height=500,left=200,top=100');
69
+ if (!myWindow) {
70
+ // Blocked by popup-blocker
71
+ // eslint-disable-next-line prefer-promise-reject-errors
72
+ return reject("blocked");
73
+ }
74
+ checkWindowClosed = setInterval(() => {
75
+ if (myWindow.closed) {
76
+ clearInterval(checkWindowClosed);
77
+ // eslint-disable-next-line prefer-promise-reject-errors
78
+ reject("closed");
79
+ }
80
+ }, 500);
81
+ try {
82
+ myWindow.addEventListener("load", myWinOnLoad, true);
83
+ }
84
+ catch (e) {
85
+ // eslint-disable-next-line no-console
86
+ console.log("authjs(login): Exception trying to add onload handler to opened window;");
87
+ }
88
+ };
89
+ const fnCloseIframe = () => {
90
+ elIframe.parentNode.removeChild(elIframe);
91
+ elCloseBtn.parentNode.removeChild(elCloseBtn);
92
+ // eslint-disable-next-line no-multi-assign
93
+ elIframe = elCloseBtn = null;
94
+ bWinIframe = false;
95
+ };
96
+ const fnCloseAndReject = () => {
97
+ fnCloseIframe();
98
+ // eslint-disable-next-line prefer-promise-reject-errors
99
+ reject("closed");
100
+ };
101
+ // If there is a userIdentifier and password specified or an external SSO auth service,
102
+ // we can try to use this silently in an iFrame first
103
+ if (bWinIframe) {
104
+ const nFrameZLevel = 99999;
105
+ elIframe = document.createElement('iframe');
106
+ // eslint-disable-next-line prefer-template
107
+ elIframe.id = 'pe' + this.config.clientId;
108
+ const loginBoxWidth = 500;
109
+ const loginBoxHeight = 700;
110
+ const oStyle = elIframe.style;
111
+ oStyle.position = 'absolute';
112
+ oStyle.display = 'none';
113
+ oStyle.zIndex = nFrameZLevel;
114
+ oStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2)}px`;
115
+ oStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2)}px`;
116
+ oStyle.width = '500px';
117
+ oStyle.height = '700px';
118
+ // Add Iframe to top of document DOM to have it load
119
+ document.body.insertBefore(elIframe, document.body.firstChild);
120
+ // Add Iframe to DOM to have it load
121
+ document.getElementsByTagName('body')[0].appendChild(elIframe);
122
+ elIframe.addEventListener("load", myWinOnLoad, true);
123
+ // Disallow iframe content attempts to navigate main window
124
+ elIframe.setAttribute("sandbox", "allow-scripts allow-forms allow-same-origin");
125
+ elIframe.setAttribute('src', url);
126
+ const svgCloseBtn = `<?xml version="1.0" encoding="UTF-8"?>
127
+ <svg width="34px" height="34px" viewBox="0 0 34 34" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
128
+ <title>Dismiss - Black</title>
129
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
130
+ <g transform="translate(1.000000, 1.000000)">
131
+ <circle fill="#252C32" cx="16" cy="16" r="16"></circle>
132
+ <g transform="translate(9.109375, 9.214844)" fill="#FFFFFF" fill-rule="nonzero">
133
+ <path d="M12.7265625,0 L0,12.6210938 L1.0546875,13.5703125 L13.78125,1.0546875 L12.7265625,0 Z M13.7460938,12.5507812 L1.01953125,0 L0,1.01953125 L12.7617188,13.6054688 L13.7460938,12.5507812 Z"></path>
134
+ </g>
135
+ </g>
136
+ </g>
137
+ </svg>`;
138
+ const bCloseWithinFrame = false;
139
+ elCloseBtn = document.createElement('img');
140
+ elCloseBtn.onclick = fnCloseAndReject;
141
+ // eslint-disable-next-line prefer-template
142
+ elCloseBtn.src = 'data:image/svg+xml;base64,' + window.btoa(svgCloseBtn);
143
+ const oBtnStyle = elCloseBtn.style;
144
+ oBtnStyle.cursor = 'pointer';
145
+ // If svg doesn't set width and height might want to set oBtStyle width and height to something like '2em'
146
+ oBtnStyle.position = 'absolute';
147
+ oBtnStyle.display = 'none';
148
+ oBtnStyle.zIndex = nFrameZLevel + 1;
149
+ const nTopOffset = bCloseWithinFrame ? 5 : -10;
150
+ const nRightOffset = bCloseWithinFrame ? -34 : -20;
151
+ oBtnStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2) + nTopOffset}px`;
152
+ oBtnStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2) + loginBoxWidth + nRightOffset}px`;
153
+ document.body.insertBefore(elCloseBtn, document.body.firstChild);
154
+ // If the password was wrong, then the login screen will be in the iframe
155
+ // ..and with Pega without realization of US-372314 it may replace the top (main portal) window
156
+ // For now set a timer and if the timer expires, remove the iFrame and use same url within
157
+ // visible window
158
+ tmrAuthComplete = setTimeout(() => {
159
+ clearTimeout(tmrAuthComplete);
160
+ // remove password from config
161
+ if (this.config.password) {
162
+ delete this.config.password;
163
+ __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
164
+ }
165
+ if (this.config.iframeLoginUI) {
166
+ elIframe.style.display = "block";
167
+ elCloseBtn.style.display = "block";
168
+ }
169
+ else {
170
+ fnCloseIframe();
171
+ fnOpenPopup();
172
+ }
173
+ }, iframeTimeout);
174
+ }
175
+ else {
176
+ fnOpenPopup();
177
+ }
178
+ let authMessageReceiver = null;
179
+ /* Retrieve token(s) and close login window */
180
+ const fnGetTokenAndFinish = (code) => {
181
+ window.removeEventListener("message", authMessageReceiver, false);
182
+ this.getToken(code).then(token => {
183
+ if (bWinIframe) {
184
+ clearTimeout(tmrAuthComplete);
185
+ fnCloseIframe();
186
+ }
187
+ else {
188
+ clearInterval(checkWindowClosed);
189
+ try {
190
+ myWindow.close();
191
+ }
192
+ catch (e) {
193
+ // eslint-disable-next-line no-console
194
+ console.warn(`attempt to close opened window failed`);
195
+ }
196
+ }
197
+ resolve(token);
198
+ })
199
+ .catch(e => {
200
+ reject(e);
201
+ });
202
+ };
203
+ /* Handler to receive the auth code */
204
+ authMessageReceiver = (event) => {
205
+ // Check origin to make sure it is the redirect origin
206
+ if (event.origin !== redirectOrigin) {
207
+ // eslint-disable-next-line no-console
208
+ console.info(`Received event from unexpected origin: ${event.origin} (was expecting: ${redirectOrigin})`);
209
+ }
210
+ if (!event.data || !event.data.type || event.data.type !== "PegaAuth")
211
+ return;
212
+ // eslint-disable-next-line no-console
213
+ console.log("authjs(login): postMessage received with code");
214
+ const code = event.data.code.toString();
215
+ fnGetTokenAndFinish(code);
216
+ };
217
+ window.addEventListener("message", authMessageReceiver, false);
218
+ window.authCodeCallback = (code) => {
219
+ // eslint-disable-next-line no-console
220
+ console.log("authjs(login): authCodeCallback used with code");
221
+ fnGetTokenAndFinish(code);
222
+ };
223
+ });
224
+ });
64
225
  }
65
226
  // Login redirect
66
227
  loginRedirect() {
@@ -71,131 +232,71 @@ class PegaAuth {
71
232
  location.href = url;
72
233
  });
73
234
  }
74
- // check state
75
- checkStateMatch(state) {
76
- return state === __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state;
77
- }
78
235
  // For PKCE token endpoint includes code_verifier
79
236
  getToken(authCode) {
80
237
  // Reload config to pick up the previously stored codeVerifier
81
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_reloadConfig).call(this);
82
- const { serverType, isolationId, clientId, clientSecret, tokenUri, grantType, customTokenParams, userIdentifier, password, noPKCE } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
83
- const { sessionIndex, acRedirectUri, codeVerifier } = __classPrivateFieldGet(this, _PegaAuth_dynState, "f");
84
- const bAuthCode = !grantType || grantType === 'authCode';
85
- if (bAuthCode && !authCode && !this.isNode) {
86
- const queryString = window.location.search;
87
- const urlParams = new URLSearchParams(queryString);
88
- authCode = urlParams.get('code');
89
- }
238
+ this.reloadConfig();
239
+ const { clientId, clientSecret, redirectUri, tokenUri, codeVerifier } = this.config;
240
+ // eslint-disable-next-line no-restricted-globals
241
+ const queryString = location.search;
242
+ const urlParams = new URLSearchParams(queryString);
243
+ const code = authCode || urlParams.get("code");
90
244
  const formData = new URLSearchParams();
91
- formData.append('client_id', clientId);
245
+ formData.append("client_id", clientId);
92
246
  if (clientSecret) {
93
- formData.append('client_secret', clientSecret);
94
- }
95
- /* eslint-disable camelcase */
96
- const fullGTName = {
97
- authCode: 'authorization_code',
98
- clientCreds: 'client_credentials',
99
- customBearer: 'custom-bearer',
100
- passwordCreds: 'password'
101
- }[grantType];
102
- const grant_type = fullGTName || grantType || 'authorization_code';
103
- formData.append('grant_type', grant_type);
104
- if (serverType === 'launchpad' && grantType !== 'authCode') {
105
- formData.append('isolation_ids', isolationId);
106
- }
107
- if (bAuthCode) {
108
- formData.append('code', authCode);
109
- formData.append('redirect_uri', acRedirectUri);
110
- if (!noPKCE) {
111
- formData.append('code_verifier', codeVerifier);
112
- }
113
- }
114
- else if (sessionIndex) {
115
- formData.append('session_index', sessionIndex);
116
- }
117
- /* eslint-enable camelcase */
118
- if (grantType === 'customBearer' && customTokenParams) {
119
- Object.keys(customTokenParams).forEach((param) => {
120
- formData.append(param, customTokenParams[param]);
121
- });
122
- }
123
- if (grantType !== 'authCode') {
124
- formData.append('enable_psyncId', 'true');
125
- }
126
- if (grantType === 'passwordCreds') {
127
- formData.append('username', userIdentifier);
128
- formData.append('password', atob(password));
247
+ formData.append("client_secret", clientSecret);
129
248
  }
249
+ formData.append("grant_type", "authorization_code");
250
+ formData.append("code", code);
251
+ formData.append("redirect_uri", redirectUri);
252
+ formData.append("code_verifier", codeVerifier);
130
253
  return fetch(tokenUri, {
131
- agent: __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_getAgent).call(this),
132
- method: 'POST',
254
+ method: "POST",
133
255
  headers: new Headers({
134
- 'content-type': this.urlencoded
256
+ "content-type": "application/x-www-form-urlencoded",
135
257
  }),
136
- body: formData.toString()
258
+ body: formData.toString(),
137
259
  })
138
260
  .then((response) => response.json())
139
- .then((token) => {
140
- if (token.errors || token.error) {
141
- // eslint-disable-next-line no-console
142
- console.error(`Token endpoint error: ${JSON.stringify(token.errors || token.error)}`);
261
+ .then(token => {
262
+ // .expires_in contains the # of seconds before access token expires
263
+ // add property to keep track of current time when the token expires
264
+ token.eA = Date.now() + (token.expires_in * 1000);
265
+ if (this.config.codeVerifier) {
266
+ delete this.config.codeVerifier;
143
267
  }
144
- else {
145
- // .expires_in contains the # of seconds before access token expires
146
- // add property to keep track of current time when the token expires
147
- token.eA = Date.now() + token.expires_in * 1000;
148
- // Clear authCode related config state: state, codeVerifier, acRedirectUri
149
- if (__classPrivateFieldGet(this, _PegaAuth_dynState, "f").state) {
150
- delete __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state;
151
- }
152
- if (__classPrivateFieldGet(this, _PegaAuth_dynState, "f").codeVerifier) {
153
- delete __classPrivateFieldGet(this, _PegaAuth_dynState, "f").codeVerifier;
154
- }
155
- if (__classPrivateFieldGet(this, _PegaAuth_dynState, "f").acRedirectUri) {
156
- delete __classPrivateFieldGet(this, _PegaAuth_dynState, "f").acRedirectUri;
157
- }
158
- // If there is a session_index then move this to the peConfig structure (as used on authorize)
159
- if (token.session_index) {
160
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndex = token.session_index;
161
- }
162
- // If we got a token and have a session index, then reset the sessionIndexAttempts
163
- if (__classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndex) {
164
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndexAttempts = 0;
165
- }
166
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
268
+ // If there is a session_index then move this to the peConfig structure (as used on authorize)
269
+ if (token.session_index) {
270
+ this.config.sessionIndex = token.session_index;
167
271
  }
272
+ // If we got a token and have a session index, then reset the sessionIndexAttempts
273
+ if (this.config.sessionIndex) {
274
+ this.config.sessionIndexAttempts = 0;
275
+ }
276
+ __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
168
277
  return token;
169
278
  })
170
- .catch((e) => {
279
+ .catch(e => {
171
280
  // eslint-disable-next-line no-console
172
- console.error(`Token endpoint error: ${e}`);
281
+ console.log(e);
173
282
  });
174
283
  }
175
284
  /* eslint-disable camelcase */
176
285
  async refreshToken(refresh_token) {
177
- const { clientId, clientSecret, tokenUri } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
178
- if (this.isNode && !this.crypto) {
179
- // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
180
- await __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importNodeLibs).call(this);
181
- }
182
- if (!refresh_token) {
183
- return null;
184
- }
286
+ const { clientId, clientSecret, tokenUri } = this.config;
185
287
  const formData = new URLSearchParams();
186
- formData.append('client_id', clientId);
288
+ formData.append("client_id", clientId);
187
289
  if (clientSecret) {
188
- formData.append('client_secret', clientSecret);
290
+ formData.append("client_secret", clientSecret);
189
291
  }
190
- formData.append('grant_type', 'refresh_token');
191
- formData.append('refresh_token', refresh_token);
292
+ formData.append("grant_type", "refresh_token");
293
+ formData.append("refresh_token", refresh_token);
192
294
  return fetch(tokenUri, {
193
- agent: __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_getAgent).call(this),
194
- method: 'POST',
295
+ method: "POST",
195
296
  headers: new Headers({
196
- 'content-type': this.urlencoded
297
+ "content-type": "application/x-www-form-urlencoded",
197
298
  }),
198
- body: formData.toString()
299
+ body: formData.toString(),
199
300
  })
200
301
  .then((response) => {
201
302
  if (!response.ok && response.status === 401) {
@@ -203,550 +304,142 @@ class PegaAuth {
203
304
  }
204
305
  return response.json();
205
306
  })
206
- .then((token) => {
307
+ .then(token => {
207
308
  if (token) {
208
309
  // .expires_in contains the # of seconds before access token expires
209
310
  // add property to keep track of current time when the token expires
210
- token.eA = Date.now() + token.expires_in * 1000;
311
+ token.eA = Date.now() + (token.expires_in * 1000);
211
312
  }
212
313
  return token;
213
314
  })
214
- .catch((e) => {
315
+ .catch(e => {
215
316
  // eslint-disable-next-line no-console
216
- console.warn(`Refresh token failed: ${e}`);
217
- return null;
317
+ console.log(e);
218
318
  });
219
319
  }
220
320
  async revokeTokens(access_token, refresh_token = null) {
221
- if (Object.keys(__classPrivateFieldGet(this, _PegaAuth_config, "f")).length === 0) {
222
- // Must have a config structure to proceed
321
+ if (!this.config || !this.config.revokeUri) {
322
+ // Must have a config structure and revokeUri to proceed
223
323
  return;
224
324
  }
225
- const { clientId, clientSecret, revokeUri } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
226
- if (this.isNode && !this.crypto) {
227
- // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
228
- await __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importNodeLibs).call(this);
229
- }
230
- const hdrs = { 'content-type': this.urlencoded };
325
+ const { clientId, clientSecret, revokeUri } = this.config;
326
+ const hdrs = { "content-type": "application/x-www-form-urlencoded" };
231
327
  if (clientSecret) {
232
- const basicCreds = btoa(`${clientId}:${clientSecret}`);
233
- hdrs.authorization = `Basic ${basicCreds}`;
328
+ const creds = `${clientId}:${clientSecret}`;
329
+ hdrs.authorization = `Basic ${window.btoa(creds)}`;
234
330
  }
235
- const aTknProps = ['access_token'];
331
+ const aTknProps = ["access_token"];
236
332
  if (refresh_token) {
237
- aTknProps.push('refresh_token');
333
+ aTknProps.push("refresh_token");
238
334
  }
239
335
  aTknProps.forEach((prop) => {
240
336
  const formData = new URLSearchParams();
241
337
  if (!clientSecret) {
242
- formData.append('client_id', clientId);
338
+ formData.append("client_id", clientId);
243
339
  }
244
- formData.append('token', prop === 'access_token' ? access_token : refresh_token);
245
- formData.append('token_type_hint', prop);
340
+ formData.append("token", prop === "access_token" ? access_token : refresh_token);
341
+ formData.append("token_type_hint", prop);
246
342
  fetch(revokeUri, {
247
- agent: __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_getAgent).call(this),
248
- method: 'POST',
343
+ method: "POST",
249
344
  headers: new Headers(hdrs),
250
- body: formData.toString()
345
+ body: formData.toString(),
251
346
  })
252
347
  .then((response) => {
253
348
  if (!response.ok) {
254
349
  // eslint-disable-next-line no-console
255
- console.error(`Error revoking ${prop}:${response.status}`);
350
+ console.log(`Error revoking ${prop}:${response.status}`);
256
351
  }
257
352
  })
258
- .catch((e) => {
353
+ .catch(e => {
259
354
  // eslint-disable-next-line no-console
260
- console.error(`Error revoking ${prop}; ${e}`);
355
+ console.log(e);
261
356
  });
262
357
  });
263
- __classPrivateFieldGet(this, _PegaAuth_config, "f").silentAuthFailed = false;
264
358
  // Also clobber any sessionIndex
265
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateSessionIndex).call(this, null);
359
+ if (this.config.sessionIndex) {
360
+ delete this.config.sessionIndex;
361
+ __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
362
+ }
266
363
  }
267
- }
268
- _PegaAuth_config = new WeakMap(), _PegaAuth_dynState = new WeakMap(), _PegaAuth_instances = new WeakSet(), _PegaAuth_reloadSS = function _PegaAuth_reloadSS(ssKey) {
269
- const sItem = window.sessionStorage.getItem(ssKey);
270
- let obj = {};
271
- if (sItem) {
272
- try {
273
- obj = JSON.parse(sItem);
364
+ // For userinfo endpoint to return meaningful data, endpoint must include appAlias (if specified) and authorize must
365
+ // specify profile and optionally email scope to get such info returned
366
+ async getUserinfo(access_token) {
367
+ if (!this.config || !this.config.userinfoUri) {
368
+ // Must have a config structure and userInfo to proceed
369
+ return {};
274
370
  }
275
- catch (e) {
276
- try {
277
- obj = JSON.parse(atob(sItem));
371
+ const hdrs = { 'authorization': `bearer ${access_token}`, 'content-type': 'application/json;charset=UTF-8' };
372
+ return fetch(this.config.userinfoUri, {
373
+ method: "GET",
374
+ headers: new Headers(hdrs)
375
+ })
376
+ .then(response => {
377
+ if (response.ok) {
378
+ return response.json();
278
379
  }
279
- catch (err) {
280
- obj = {};
380
+ else {
381
+ // eslint-disable-next-line no-console
382
+ console.log(`Error invoking userinfo: ${response.status}`);
281
383
  }
282
- }
283
- }
284
- if (ssKey === this.ssKeyConfig) {
285
- __classPrivateFieldSet(this, _PegaAuth_config, sItem ? obj : {}, "f");
286
- }
287
- else {
288
- __classPrivateFieldSet(this, _PegaAuth_dynState, sItem ? obj : {}, "f");
289
- }
290
- }, _PegaAuth_reloadConfig = function _PegaAuth_reloadConfig() {
291
- if (this.ssKeyConfig) {
292
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_reloadSS).call(this, this.ssKeyConfig);
293
- }
294
- if (this.ssKeyDynState) {
295
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_reloadSS).call(this, this.ssKeyDynState);
296
- }
297
- }, _PegaAuth_updateConfig = function _PegaAuth_updateConfig() {
298
- // transform must occur unless it is explicitly disabled
299
- const transform = __classPrivateFieldGet(this, _PegaAuth_config, "f").transform !== false;
300
- // May not need to write out Config info all the time, but there is a scenario where a
301
- // non obfuscated value is passed in and then it needs to be obfuscated
302
- if (this.ssKeyConfig) {
303
- const sConfig = JSON.stringify(__classPrivateFieldGet(this, _PegaAuth_config, "f"));
304
- window.sessionStorage.setItem(this.ssKeyConfig, transform ? btoa(sConfig) : sConfig);
305
- }
306
- if (this.ssKeyDynState) {
307
- const sDynState = JSON.stringify(__classPrivateFieldGet(this, _PegaAuth_dynState, "f"));
308
- window.sessionStorage.setItem(this.ssKeyDynState, transform ? btoa(sDynState) : sDynState);
309
- }
310
- if (__classPrivateFieldGet(this, _PegaAuth_config, "f").fnDynStateChangedCB) {
311
- __classPrivateFieldGet(this, _PegaAuth_config, "f").fnDynStateChangedCB();
312
- }
313
- }, _PegaAuth_importSingleLib = async function _PegaAuth_importSingleLib(libName, libProp, bLoadAlways = false) {
314
- // eslint-disable-next-line no-undef
315
- if (!bLoadAlways && typeof (this.isNode ? global : window)[libProp] !== 'undefined') {
316
- // eslint-disable-next-line no-undef
317
- this[libProp] = (this.isNode ? global : window)[libProp];
318
- return this[libProp];
384
+ })
385
+ .then(data => {
386
+ return data;
387
+ })
388
+ .catch(e => {
389
+ // eslint-disable-next-line no-console
390
+ console.log(e);
391
+ });
319
392
  }
320
- // Needed to explicitly make import argument a string by using template literals to fix a compile
321
- // error: Critical dependency: the request of a dependency is an expression
322
- return import(`${libName}`)
323
- .then((mod) => {
324
- this[libProp] = mod.default;
325
- })
326
- .catch((e) => {
327
- // eslint-disable-next-line no-console
328
- console.error(`Library ${libName} failed to load. ${e}`);
329
- throw e;
330
- });
331
- }, _PegaAuth_importNodeLibs = async function _PegaAuth_importNodeLibs() {
332
- // Also current assumption is using Node 18 or better
333
- // With 18.3 there is now a native fetch (but may want to force use of node-fetch)
334
- const useNodeFetch = !!__classPrivateFieldGet(this, _PegaAuth_config, "f").useNodeFetch;
335
- return Promise.all([
336
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importSingleLib).call(this, 'node-fetch', 'fetch', useNodeFetch),
337
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importSingleLib).call(this, 'open', 'open'),
338
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importSingleLib).call(this, 'node:crypto', 'crypto', true),
339
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importSingleLib).call(this, 'node:https', 'https'),
340
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importSingleLib).call(this, 'node:http', 'http'),
341
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_importSingleLib).call(this, 'node:fs', 'fs')
342
- ]).then(() => {
343
- this.subtle = this.crypto?.subtle || this.crypto.webcrypto.subtle;
344
- if ((typeof fetch === 'undefined' || useNodeFetch) && this.fetch) {
345
- /* eslint-disable-next-line no-global-assign */
346
- fetch = this.fetch;
347
- }
348
- });
393
+ }
394
+ _PegaAuth_instances = new WeakSet(), _PegaAuth_updateConfig = function _PegaAuth_updateConfig() {
395
+ const sSI = JSON.stringify(this.config);
396
+ window.sessionStorage.setItem(this.ssKeyConfig, this.bEncodeSI ? window.btoa(sSI) : sSI);
349
397
  }, _PegaAuth_buildAuthorizeUrl =
350
398
  // For PKCE the authorize includes a code_challenge & code_challenge_method as well
351
399
  async function _PegaAuth_buildAuthorizeUrl(state) {
352
- const { serverType, clientId, redirectUri, authorizeUri, authService, appAlias, userIdentifier, password, noPKCE, isolationId } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
353
- const { sessionIndex, } = __classPrivateFieldGet(this, _PegaAuth_dynState, "f");
354
- const bInfinity = serverType === 'infinity';
355
- if (!noPKCE) {
356
- // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars
357
- const buf = new Uint8Array(64);
358
- this.crypto.getRandomValues(buf);
359
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").codeVerifier = __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_base64UrlSafeEncode).call(this, buf);
360
- }
400
+ const { clientId, redirectUri, authorizeUri, authService, sessionIndex, appAlias, useLocking, userIdentifier, password } = this.config;
401
+ // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars
402
+ let buf = new Uint8Array(64);
403
+ window.crypto.getRandomValues(buf);
404
+ this.config.codeVerifier = __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_base64UrlSafeEncode).call(this, buf);
361
405
  // If sessionIndex exists then increment attempts count (we will stop sending session_index after two failures)
362
- // With Infinity '24 we can now properly detect a invalid_session_index error, but can't for earlier versions
363
406
  if (sessionIndex) {
364
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndexAttempts += 1;
407
+ this.config.sessionIndexAttempts += 1;
365
408
  }
366
- // We use state to verify that the received code is for the right authorize transaction
367
- // eslint-disable-next-line no-unneeded-ternary
368
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state = `${state ? state : ''}.${__classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_getRandomString).call(this, 32)}`;
369
- // The same redirectUri needs to be provided to token endpoint, so save this away incase redirectUri is
370
- // adjusted for next authorize
371
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").acRedirectUri = redirectUri;
372
409
  // Persist codeVerifier in session storage so it survives the redirects that are to follow
373
410
  __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
411
+ if (!state) {
412
+ // Calc random state variable
413
+ buf = new Uint8Array(32);
414
+ window.crypto.getRandomValues(buf);
415
+ state = __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_base64UrlSafeEncode).call(this, buf);
416
+ }
374
417
  // Trim alias to include just the real alias piece
375
- const addtlScope = appAlias ? `+app.alias.${appAlias.replace(/^app\//, '')}` : '';
376
- const scope = bInfinity ? `openid${addtlScope}` : 'user_info';
418
+ const addtlScope = appAlias ? `+app.alias.${appAlias.replace(/^app\//, '')}` : "";
377
419
  // Add explicit creds if specified to try to avoid login popup
378
- const authServiceArg = authService ? `&authentication_service=${encodeURIComponent(authService)}` : '';
379
- const sessionIndexArg = sessionIndex && __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : '';
380
- const userIdentifierArg = userIdentifier ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}` : '';
381
- const passwordArg = password && userIdentifier ? `&Password=${encodeURIComponent(atob(password))}` : '';
382
- const moreAuthArgs = bInfinity
383
- ? `&enable_psyncId=true${authServiceArg}${sessionIndexArg}${userIdentifierArg}${passwordArg}`
384
- : `&isolationID=${isolationId}`;
385
- let pkceArgs = '';
386
- if (!noPKCE) {
387
- const cc = await __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_getCodeChallenge).call(this, __classPrivateFieldGet(this, _PegaAuth_dynState, "f").codeVerifier);
388
- pkceArgs = `&code_challenge=${cc}&code_challenge_method=S256`;
389
- }
390
- return `${authorizeUri}?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&scope=${scope}&state=${__classPrivateFieldGet(this, _PegaAuth_dynState, "f").state}${pkceArgs}${moreAuthArgs}`;
391
- }, _PegaAuth_authCodeStart =
392
- // authCode login issues the authorize endpoint transaction and deals with redirects
393
- async function _PegaAuth_authCodeStart() {
394
- const fnGetRedirectUriOrigin = () => {
395
- const redirectUri = __classPrivateFieldGet(this, _PegaAuth_config, "f").redirectUri;
396
- const nRootOffset = redirectUri.indexOf('//');
397
- const nFirstPathOffset = nRootOffset !== -1 ? redirectUri.indexOf('/', nRootOffset + 2) : -1;
398
- return nFirstPathOffset !== -1 ? redirectUri.substring(0, nFirstPathOffset) : redirectUri;
399
- };
400
- const redirectOrigin = fnGetRedirectUriOrigin();
401
- const state = this.isNode ? '' : btoa(window.location.origin);
402
- return new Promise((resolve, reject) => {
403
- let theUrl = null; // holds the crafted authorize url
404
- let myWindow = null; // popup or iframe
405
- let elIframe = null;
406
- let elCloseBtn = null;
407
- const iframeTimeout = __classPrivateFieldGet(this, _PegaAuth_config, "f").silentTimeout !== undefined ? __classPrivateFieldGet(this, _PegaAuth_config, "f").silentTimeout : 5000;
408
- let bWinIframe = true;
409
- let tmrAuthComplete = null;
410
- let checkWindowClosed = null;
411
- let bDisablePromptNone = false;
412
- const myWinOnLoad = () => {
413
- try {
414
- if (bWinIframe) {
415
- elIframe.contentWindow.postMessage({ type: 'PegaAuth' }, redirectOrigin);
416
- }
417
- else {
418
- myWindow.postMessage({ type: 'PegaAuth' }, redirectOrigin);
419
- }
420
- }
421
- catch (e) {
422
- // Exception trying to postMessage on load (perhaps should console.warn)
423
- }
424
- };
425
- const fnSetSilentAuthFailed = (bSet) => {
426
- __classPrivateFieldGet(this, _PegaAuth_config, "f").silentAuthFailed = bSet;
427
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
428
- };
429
- /* eslint-disable prefer-promise-reject-errors */
430
- const fnOpenPopup = () => {
431
- if (__classPrivateFieldGet(this, _PegaAuth_config, "f").noPopups) {
432
- return reject('no-popups');
433
- }
434
- // Since displaying a visible window, clear the silent auth failed flag
435
- fnSetSilentAuthFailed(false);
436
- myWindow = (this.isNode ? this.open : window.open)(theUrl, '_blank', 'width=700,height=500,left=200,top=100');
437
- if (!myWindow) {
438
- // Blocked by popup-blocker
439
- return reject('blocked');
440
- }
441
- checkWindowClosed = setInterval(() => {
442
- if (myWindow.closed) {
443
- clearInterval(checkWindowClosed);
444
- reject('closed');
445
- }
446
- }, 500);
447
- if (!this.isNode) {
448
- try {
449
- myWindow.addEventListener('load', myWinOnLoad, true);
450
- }
451
- catch (e) {
452
- // Exception trying to add onload handler to opened window
453
- // eslint-disable-next-line no-console
454
- console.error(`Error adding event listener on popup window: ${e}`);
455
- }
456
- }
457
- };
458
- /* eslint-enable prefer-promise-reject-errors */
459
- const fnCloseIframe = () => {
460
- elIframe.parentNode.removeChild(elIframe);
461
- elCloseBtn.parentNode.removeChild(elCloseBtn);
462
- elIframe = null;
463
- elCloseBtn = null;
464
- bWinIframe = false;
465
- };
466
- const fnCloseAndReject = () => {
467
- fnCloseIframe();
468
- /* eslint-disable-next-line prefer-promise-reject-errors */
469
- reject('closed');
470
- };
471
- const fnAuthMessageReceiver = (event) => {
472
- // Check origin to make sure it is the redirect origin
473
- if (event.origin !== redirectOrigin)
474
- return;
475
- if (!event.data || !event.data.type || event.data.type !== 'PegaAuth')
476
- return;
477
- const aArgs = ['code', 'state', 'error', 'errorDesc'];
478
- const aValues = [];
479
- for (let i = 0; i < aArgs.length; i += 1) {
480
- const arg = aArgs[i];
481
- aValues[arg] = event.data[arg] ? event.data[arg].toString() : null;
482
- }
483
- if (aValues.error || (aValues.code && aValues.state === __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state)) {
484
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
485
- fnGetTokenAndFinish(aValues.code, aValues.error, aValues.errorDesc);
486
- }
487
- };
488
- const fnEnableMessageReceiver = (bEnable) => {
489
- if (bEnable) {
490
- window.addEventListener('message', fnAuthMessageReceiver, false);
491
- window.authCodeCallback = (code, state1, error, errorDesc) => {
492
- if (error || (code && state1 === __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state)) {
493
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
494
- fnGetTokenAndFinish(code, error, errorDesc);
495
- }
496
- };
497
- }
498
- else {
499
- window.removeEventListener('message', fnAuthMessageReceiver, false);
500
- delete window.authCodeCallback;
501
- }
502
- };
503
- const doAuthorize = () => {
504
- // If there is a userIdentifier and password specified or an external SSO auth service,
505
- // we can try to use this silently in an iFrame first
506
- bWinIframe =
507
- !this.isNode &&
508
- !__classPrivateFieldGet(this, _PegaAuth_config, "f").silentAuthFailed &&
509
- iframeTimeout > 0 &&
510
- ((!!__classPrivateFieldGet(this, _PegaAuth_config, "f").userIdentifier && !!__classPrivateFieldGet(this, _PegaAuth_config, "f").password) ||
511
- __classPrivateFieldGet(this, _PegaAuth_config, "f").iframeLoginUI ||
512
- __classPrivateFieldGet(this, _PegaAuth_config, "f").authService !== 'pega');
513
- // Enable message receiver
514
- if (!this.isNode) {
515
- fnEnableMessageReceiver(true);
516
- }
517
- if (bWinIframe) {
518
- const nFrameZLevel = 99999;
519
- elIframe = document.createElement('iframe');
520
- elIframe.id = `pe${__classPrivateFieldGet(this, _PegaAuth_config, "f").clientId}`;
521
- const loginBoxWidth = 500;
522
- const loginBoxHeight = 700;
523
- const oStyle = elIframe.style;
524
- oStyle.position = 'absolute';
525
- oStyle.display = 'none';
526
- oStyle.zIndex = nFrameZLevel;
527
- oStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2)}px`;
528
- oStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2)}px`;
529
- oStyle.width = '500px';
530
- oStyle.height = '700px';
531
- // Add Iframe to top of document DOM to have it load
532
- document.body.insertBefore(elIframe, document.body.firstChild);
533
- // document.getElementsByTagName('body')[0].appendChild(elIframe);
534
- elIframe.addEventListener('load', myWinOnLoad, true);
535
- // Disallow iframe content attempts to navigate main window
536
- elIframe.setAttribute('sandbox', 'allow-scripts allow-forms allow-same-origin');
537
- // Adding prompt=none as this is standard OIDC way to communicate no UI is expected (expecting Pega security to support this one day)
538
- elIframe.setAttribute('src', bDisablePromptNone ? theUrl : `${theUrl}&prompt=none`);
539
- const svgCloseBtn = `<?xml version="1.0" encoding="UTF-8"?>
540
- <svg width="34px" height="34px" viewBox="0 0 34 34" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
541
- <title>Dismiss - Black</title>
542
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
543
- <g transform="translate(1.000000, 1.000000)">
544
- <circle fill="#252C32" cx="16" cy="16" r="16"></circle>
545
- <g transform="translate(9.109375, 9.214844)" fill="#FFFFFF" fill-rule="nonzero">
546
- <path d="M12.7265625,0 L0,12.6210938 L1.0546875,13.5703125 L13.78125,1.0546875 L12.7265625,0 Z M13.7460938,12.5507812 L1.01953125,0 L0,1.01953125 L12.7617188,13.6054688 L13.7460938,12.5507812 Z"></path>
547
- </g>
548
- </g>
549
- </g>
550
- </svg>`;
551
- const bCloseWithinFrame = false;
552
- elCloseBtn = document.createElement('img');
553
- elCloseBtn.onclick = fnCloseAndReject;
554
- elCloseBtn.src = `data:image/svg+xml;base64,${btoa(svgCloseBtn)}`;
555
- const oBtnStyle = elCloseBtn.style;
556
- oBtnStyle.cursor = 'pointer';
557
- // If svg doesn't set width and height might want to set oBtStyle width and height to something like '2em'
558
- oBtnStyle.position = 'absolute';
559
- oBtnStyle.display = 'none';
560
- oBtnStyle.zIndex = nFrameZLevel + 1;
561
- const nTopOffset = bCloseWithinFrame ? 5 : -10;
562
- const nRightOffset = bCloseWithinFrame ? -34 : -20;
563
- const nTop = Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2) + nTopOffset;
564
- oBtnStyle.top = `${nTop}px`;
565
- const nLeft = Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2) + loginBoxWidth + nRightOffset;
566
- oBtnStyle.left = `${nLeft}px`;
567
- document.body.insertBefore(elCloseBtn, document.body.firstChild);
568
- // If the password was wrong, then the login screen will be in the iframe
569
- // ..and with Pega without realization of US-372314 it may replace the top (main portal) window
570
- // For now set a timer and if the timer expires, remove the iFrame and use same url within
571
- // visible window
572
- tmrAuthComplete = setTimeout(() => {
573
- clearTimeout(tmrAuthComplete);
574
- /*
575
- // remove password from config
576
- if (this.#config.password) {
577
- delete this.#config.password;
578
- this.#updateConfig();
579
- }
580
- */
581
- // Display the iframe where the redirects did not succeed (or invoke a popup window)
582
- if (__classPrivateFieldGet(this, _PegaAuth_config, "f").iframeLoginUI) {
583
- elIframe.style.display = 'block';
584
- elCloseBtn.style.display = 'block';
585
- }
586
- else {
587
- fnCloseIframe();
588
- fnOpenPopup();
589
- }
590
- }, iframeTimeout);
591
- }
592
- else {
593
- if (this.isNode) {
594
- // Determine port to listen to by extracting it from redirect uri
595
- const { redirectUri, cert, key } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
596
- const isHttp = redirectUri.startsWith('http:');
597
- const nLocalhost = redirectUri.indexOf('localhost:');
598
- const nSlash = redirectUri.indexOf('/', nLocalhost + 10);
599
- const nPort = parseInt(redirectUri.substring(nLocalhost + 10, nSlash), 10);
600
- if (nLocalhost !== -1) {
601
- const options = key && cert && !isHttp
602
- ? {
603
- key: this.fs.readFileSync(key),
604
- cert: this.fs.readFileSync(cert)
605
- }
606
- : {};
607
- const server = (isHttp ? this.http : this.https).createServer(options, (req, res) => {
608
- const { winTitle, winBodyHtml } = __classPrivateFieldGet(this, _PegaAuth_config, "f");
609
- res.writeHead(200, { 'Content-Type': 'text/html' });
610
- // Auto closing window for now. Can always leave it up and allow authConfig props to set title and bodyHtml
611
- res.end(`<html><head><title>${winTitle}</title><script>window.close();</script></head><body>${winBodyHtml}</body></html>`);
612
- const queryString = req.url.split('?')[1];
613
- const urlParams = new URLSearchParams(queryString);
614
- const code = urlParams.get('code');
615
- const state1 = urlParams.get('state');
616
- const error = urlParams.get('error');
617
- const errorDesc = urlParams.get('error_description');
618
- if (error || (code && state1 === __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state)) {
619
- // Stop receiving connections and close when all are handled.
620
- server.close();
621
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
622
- fnGetTokenAndFinish(code, error, errorDesc);
623
- }
624
- });
625
- /* eslint-enable no-undef */
626
- server.listen(nPort);
627
- }
628
- }
629
- fnOpenPopup();
630
- }
631
- };
632
- /* Retrieve token(s) and close login window */
633
- const fnGetTokenAndFinish = (code, error, errorDesc) => {
634
- // Can clear state in session info at this point
635
- delete __classPrivateFieldGet(this, _PegaAuth_dynState, "f").state;
636
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
637
- if (!this.isNode) {
638
- fnEnableMessageReceiver(false);
639
- if (bWinIframe) {
640
- clearTimeout(tmrAuthComplete);
641
- fnCloseIframe();
642
- }
643
- else {
644
- clearInterval(checkWindowClosed);
645
- myWindow.close();
646
- }
647
- }
648
- if (code) {
649
- this.getToken(code)
650
- .then((token) => {
651
- resolve(token);
652
- })
653
- .catch((e) => {
654
- reject(e);
655
- });
656
- }
657
- else if (error) {
658
- // Handle some errors in a special manner and pass others back to client
659
- if (error === 'login_required') {
660
- // eslint-disable-next-line no-console
661
- console.warn('silent authentication failed...starting full authentication');
662
- const bSpecialDebugPath = false;
663
- if (bSpecialDebugPath) {
664
- fnSetSilentAuthFailed(false);
665
- bDisablePromptNone = true;
666
- }
667
- else {
668
- fnSetSilentAuthFailed(true);
669
- bDisablePromptNone = false;
670
- }
671
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_buildAuthorizeUrl).call(this, state).then((url) => {
672
- theUrl = url;
673
- doAuthorize();
674
- });
675
- }
676
- else if (error === 'invalid_session_index') {
677
- // eslint-disable-next-line no-console
678
- console.warn('auth session no longer valid...starting new session');
679
- // In these scenarios, not much user can do without just starting a new session, so do that
680
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateSessionIndex).call(this, null);
681
- fnSetSilentAuthFailed(false);
682
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_buildAuthorizeUrl).call(this, state).then((url) => {
683
- theUrl = url;
684
- doAuthorize();
685
- });
686
- }
687
- else {
688
- // eslint-disable-next-line no-console
689
- console.warn(`Authorize failed: ${error}. ${errorDesc}\nFailing authorize url: ${theUrl}`);
690
- throw new Error(error, { cause: errorDesc });
691
- }
692
- }
693
- };
694
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_buildAuthorizeUrl).call(this, state).then((url) => {
695
- theUrl = url;
696
- doAuthorize();
697
- });
420
+ const moreAuthArgs = (authService ? `&authentication_service=${encodeURIComponent(authService)}` : "") +
421
+ (sessionIndex && this.config.sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : "") +
422
+ (useLocking ? `&enable_psyncId=true` : '') +
423
+ (userIdentifier ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}` : '') +
424
+ (userIdentifier && password ? `&Password=${encodeURIComponent(window.atob(password))}` : '');
425
+ return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_getCodeChallenge).call(this, this.config.codeVerifier).then(cc => {
426
+ // Now includes new enable_psyncId=true and session_index params
427
+ return `${authorizeUri}?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&scope=openid+email+profile${addtlScope}&state=${state}&code_challenge=${cc}&code_challenge_method=S256${moreAuthArgs}`;
698
428
  });
699
- }, _PegaAuth_updateSessionIndex = function _PegaAuth_updateSessionIndex(sessionIndex) {
700
- if (sessionIndex) {
701
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndex = sessionIndex;
702
- __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndexAttempts = 0;
703
- }
704
- else if (__classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndex) {
705
- delete __classPrivateFieldGet(this, _PegaAuth_dynState, "f").sessionIndex;
706
- }
707
- __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_updateConfig).call(this);
708
429
  }, _PegaAuth_sha256Hash = function _PegaAuth_sha256Hash(str) {
709
- // Found that the Node implementation of subtle.digest is yielding incorrect results
710
- // so using a different set of apis to get expected results.
711
- if (this.isNode) {
712
- return new Promise((resolve) => {
713
- resolve(this.crypto.createHash('sha256').update(str).digest());
714
- });
715
- }
716
- return this.subtle.digest('SHA-256', new TextEncoder().encode(str));
430
+ return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(str));
717
431
  }, _PegaAuth_encode64 = function _PegaAuth_encode64(buff) {
718
- return btoa(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));
432
+ return window.btoa(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));
719
433
  }, _PegaAuth_base64UrlSafeEncode = function _PegaAuth_base64UrlSafeEncode(buf) {
720
- return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_encode64).call(this, buf).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
721
- }, _PegaAuth_getRandomString = function _PegaAuth_getRandomString(nSize) {
722
- const buf = new Uint8Array(nSize);
723
- this.crypto.getRandomValues(buf);
724
- return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_base64UrlSafeEncode).call(this, buf);
725
- }, _PegaAuth_getCodeChallenge =
726
- /* Calc code verifier if necessary
727
- */
728
- /* eslint-disable camelcase */
729
- async function _PegaAuth_getCodeChallenge(code_verifier) {
730
- return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_sha256Hash).call(this, code_verifier)
731
- .then((hashed) => {
434
+ const s = __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_encode64).call(this, buf).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
435
+ return s;
436
+ }, _PegaAuth_getCodeChallenge = function _PegaAuth_getCodeChallenge(code_verifier) {
437
+ return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_sha256Hash).call(this, code_verifier).then((hashed) => {
732
438
  return __classPrivateFieldGet(this, _PegaAuth_instances, "m", _PegaAuth_base64UrlSafeEncode).call(this, hashed);
733
- })
734
- .catch((error) => {
439
+ }).catch((error) => {
735
440
  // eslint-disable-next-line no-console
736
- console.error(`Error calculation code challenge for PKCE: ${error}`);
737
- })
738
- .finally(() => {
739
- return null;
740
- });
741
- }, _PegaAuth_getAgent = function _PegaAuth_getAgent() {
742
- if (this.isNode && __classPrivateFieldGet(this, _PegaAuth_config, "f").ignoreInvalidCerts) {
743
- const options = { rejectUnauthorized: false };
744
- if (__classPrivateFieldGet(this, _PegaAuth_config, "f").legacyTLS) {
745
- options.secureOptions = this.crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT;
746
- }
747
- return new this.https.Agent(options);
748
- }
749
- return undefined;
441
+ console.log(error);
442
+ }).finally(() => { return null; });
750
443
  };
751
444
  export default PegaAuth;
752
445
  //# sourceMappingURL=auth.js.map