@pega/custom-dx-components 0.23.18 → 0.23.20

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 (343) hide show
  1. package/package.json +3 -3
  2. package/src/tasks/authenticate/index.js +55 -15
  3. package/src/tasks/bundle/builder/webpack.config.js +12 -0
  4. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -0
  5. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +3 -0
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +2 -0
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +1 -0
  9. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +1 -0
  10. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +1 -0
  11. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +2 -0
  12. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +3 -0
  13. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -0
  14. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +2 -0
  15. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +1 -0
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +1 -0
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
  19. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +3 -0
  20. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +1 -0
  21. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +2 -0
  22. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +1 -0
  23. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +3 -0
  24. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -0
  25. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +2 -0
  26. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +1 -0
  27. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +3 -0
  28. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +2 -2
  29. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +2 -0
  30. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +1 -0
  31. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +3 -0
  32. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +1 -0
  33. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +2 -0
  34. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +1 -0
  35. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +3 -0
  36. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -0
  37. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +2 -0
  38. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +1 -0
  39. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +3 -0
  40. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -0
  41. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +2 -0
  42. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +1 -0
  43. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +3 -0
  44. package/src/tasks/create/templates/Constellation/Field/Text/index.jsx.mustache +1 -0
  45. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +2 -0
  46. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +1 -0
  47. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +3 -0
  48. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +1 -0
  49. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +2 -0
  50. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +1 -0
  51. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +1 -0
  52. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +3 -0
  53. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +1 -0
  54. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +2 -0
  55. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +1 -0
  56. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +3 -0
  57. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +1 -0
  58. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +2 -0
  59. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +1 -0
  60. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +3 -0
  61. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +1 -0
  62. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +2 -0
  63. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +1 -0
  64. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +3 -0
  65. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -0
  66. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +2 -0
  67. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +1 -0
  68. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +1 -0
  69. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +3 -0
  70. package/src/tasks/create/templates/Constellation/Field/TimeofDay/index.jsx.mustache +1 -0
  71. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +2 -0
  72. package/src/tasks/create/templates/Constellation/Field/TimeofDay/styles.js.mustache +1 -0
  73. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
  74. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +1 -0
  75. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +8 -5
  76. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +1 -0
  77. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +3 -0
  78. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +1 -0
  79. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +1 -0
  80. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +2 -0
  81. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +1 -0
  82. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +2 -0
  83. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +1 -0
  84. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +3 -0
  85. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +1 -0
  86. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +2 -0
  87. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +1 -0
  88. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +2 -0
  89. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +1 -0
  90. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +2 -0
  91. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +1 -0
  92. package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +1 -0
  93. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +3 -0
  94. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +1 -0
  95. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +2 -0
  96. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +1 -0
  97. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -0
  98. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +3 -0
  99. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
  100. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +1 -0
  101. package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +1 -0
  102. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +3 -0
  103. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +1 -0
  104. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +1 -0
  105. package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +1 -0
  106. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +1 -0
  107. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +1 -0
  108. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +3 -0
  109. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +1 -0
  110. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +2 -0
  111. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +1 -0
  112. package/src/tasks/create/templates/Launchpad/Widget/CASE/demo.stories.jsx.mustache +3 -0
  113. package/src/tasks/create/templates/Launchpad/Widget/CASE/index.jsx.mustache +1 -0
  114. package/src/tasks/create/templates/Launchpad/Widget/CASE/mock.stories.js.mustache +1 -0
  115. package/src/tasks/create/templates/Launchpad/Widget/CASE/styles.js.mustache +1 -0
  116. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Avatar.jsx.mustache +1 -0
  117. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Operator.jsx.mustache +1 -0
  118. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/demo.stories.jsx.mustache +3 -0
  119. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/index.jsx.mustache +1 -0
  120. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/mock.stories.js.mustache +2 -0
  121. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/styles.js.mustache +1 -0
  122. package/src/tasks/init/template/package.json.mustache +2 -2
  123. package/tests/assets/components/create/Pega_DXIL_MyTestText/demo.stories.jsx +3 -0
  124. package/tests/assets/components/create/Pega_DXIL_MyTestText/index.jsx +1 -0
  125. package/tests/assets/components/create/Pega_DXIL_MyTestText/mock.stories.js +2 -0
  126. package/tests/assets/components/create/Pega_DXIL_MyTestText/styles.js +1 -0
  127. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/boolean-format.js +1 -0
  128. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/demo.stories.jsx +3 -0
  129. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/index.jsx +2 -1
  130. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/mock.stories.js +2 -0
  131. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/styles.js +1 -0
  132. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/demo.stories.jsx +3 -0
  133. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/index.jsx +1 -0
  134. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/mock.stories.js +1 -0
  135. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/styles.js +1 -0
  136. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/demo.stories.jsx +3 -0
  137. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/index.jsx +2 -2
  138. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/mock.stories.js +2 -0
  139. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/styles.js +1 -0
  140. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/DateFormatter.js +1 -0
  141. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/FormattedText.jsx +1 -0
  142. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/date.js +2 -0
  143. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/demo.stories.jsx +3 -0
  144. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/index.jsx +1 -0
  145. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/mock.stories.js +2 -0
  146. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/styles.js +1 -0
  147. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-time.js +1 -0
  148. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-utils.js +1 -0
  149. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date.js +1 -0
  150. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/demo.stories.jsx +3 -0
  151. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/index.jsx +1 -0
  152. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/mock.stories.js +2 -0
  153. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/styles.js +1 -0
  154. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/demo.stories.jsx +3 -0
  155. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/index.jsx +1 -0
  156. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/mock.stories.js +2 -0
  157. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/styles.js +1 -0
  158. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/StatusWork.jsx +1 -0
  159. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.jsx +3 -0
  160. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.jsx +1 -0
  161. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/mock.stories.js +3 -0
  162. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/styles.js +1 -0
  163. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/demo.stories.jsx +3 -0
  164. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/index.jsx +1 -0
  165. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/mock.stories.js +2 -0
  166. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/styles.js +1 -0
  167. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/demo.stories.jsx +3 -0
  168. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.jsx +1 -0
  169. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/mock.stories.js +2 -0
  170. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/styles.js +1 -0
  171. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/demo.stories.jsx +3 -0
  172. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/index.jsx +1 -0
  173. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/mock.stories.js +2 -0
  174. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/styles.js +1 -0
  175. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/GetNextWork.jsx +1 -0
  176. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/demo.stories.jsx +3 -0
  177. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/index.jsx +1 -0
  178. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/mock.stories.js +2 -0
  179. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/styles.js +1 -0
  180. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/utils.js +1 -0
  181. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/Avatar.jsx +1 -0
  182. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/Operator.jsx +1 -0
  183. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/demo.stories.jsx +3 -0
  184. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/index.jsx +1 -0
  185. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/mock.stories.js +2 -0
  186. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/styles.js +1 -0
  187. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/demo.stories.jsx +3 -0
  188. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/index.jsx +1 -0
  189. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/mock.stories.js +1 -0
  190. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/styles.js +1 -0
  191. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/demo.stories.jsx +3 -0
  192. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/index.jsx +1 -0
  193. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/mock.stories.js +2 -0
  194. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/styles.js +1 -0
  195. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/demo.stories.jsx +3 -0
  196. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/index.jsx +1 -0
  197. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/mock.stories.js +2 -0
  198. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/styles.js +1 -0
  199. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/demo.stories.jsx +3 -0
  200. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/index.jsx +1 -0
  201. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/mock.stories.js +2 -0
  202. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/styles.js +1 -0
  203. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/demo.stories.jsx +3 -0
  204. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/index.jsx +1 -0
  205. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/mock.stories.js +2 -0
  206. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/styles.js +1 -0
  207. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/demo.stories.jsx +3 -0
  208. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/index.jsx +1 -0
  209. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/mock.stories.js +2 -0
  210. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/styles.js +1 -0
  211. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/StatusWork.jsx +1 -0
  212. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/demo.stories.jsx +3 -0
  213. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/index.jsx +1 -0
  214. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/mock.stories.js +2 -0
  215. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/styles.js +1 -0
  216. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/demo.stories.jsx +3 -0
  217. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/index.jsx +1 -0
  218. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/mock.stories.js +2 -0
  219. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/styles.js +1 -0
  220. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/time-of-day.js +1 -0
  221. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/StatusWork.jsx +1 -0
  222. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +2 -0
  223. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.jsx +1 -0
  224. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.stories.js +2 -0
  225. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/styles.js +1 -0
  226. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +2 -0
  227. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.jsx +1 -0
  228. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/mock.stories.js +2 -0
  229. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/styles.js +1 -0
  230. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/demo.stories.jsx +3 -0
  231. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/index.jsx +1 -0
  232. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/mock.stories.js +2 -0
  233. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/styles.js +1 -0
  234. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/text-url.jsx +1 -0
  235. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/boolean-format.js +1 -0
  236. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/demo.stories.jsx +3 -0
  237. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/index.jsx +2 -1
  238. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/mock.stories.js +2 -0
  239. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/styles.js +1 -0
  240. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/demo.stories.jsx +3 -0
  241. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/index.jsx +1 -0
  242. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/mock.stories.js +1 -0
  243. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/styles.js +1 -0
  244. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/demo.stories.jsx +3 -0
  245. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/index.jsx +2 -2
  246. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/mock.stories.js +2 -0
  247. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/styles.js +1 -0
  248. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/DateFormatter.js +1 -0
  249. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/FormattedText.jsx +1 -0
  250. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/date.js +2 -0
  251. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/demo.stories.jsx +3 -0
  252. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/index.jsx +1 -0
  253. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/mock.stories.js +2 -0
  254. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/styles.js +1 -0
  255. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-time.js +1 -0
  256. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-utils.js +1 -0
  257. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date.js +1 -0
  258. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/demo.stories.jsx +3 -0
  259. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/index.jsx +1 -0
  260. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/mock.stories.js +2 -0
  261. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/styles.js +1 -0
  262. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/demo.stories.jsx +3 -0
  263. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/index.jsx +1 -0
  264. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/mock.stories.js +2 -0
  265. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/styles.js +1 -0
  266. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/StatusWork.jsx +1 -0
  267. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.jsx +3 -0
  268. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.jsx +1 -0
  269. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/mock.stories.js +3 -0
  270. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/styles.js +1 -0
  271. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/demo.stories.jsx +3 -0
  272. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/index.jsx +1 -0
  273. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/mock.stories.js +2 -0
  274. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/styles.js +1 -0
  275. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/demo.stories.jsx +3 -0
  276. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.jsx +1 -0
  277. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/mock.stories.js +2 -0
  278. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/styles.js +1 -0
  279. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/demo.stories.jsx +3 -0
  280. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/index.jsx +1 -0
  281. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/mock.stories.js +2 -0
  282. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/styles.js +1 -0
  283. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/GetNextWork.jsx +1 -0
  284. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/demo.stories.jsx +3 -0
  285. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/index.jsx +1 -0
  286. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/mock.stories.js +2 -0
  287. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/styles.js +1 -0
  288. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/utils.js +1 -0
  289. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Avatar.jsx +1 -0
  290. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Operator.jsx +1 -0
  291. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/demo.stories.jsx +3 -0
  292. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/index.jsx +1 -0
  293. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/mock.stories.js +2 -0
  294. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/styles.js +1 -0
  295. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/demo.stories.jsx +3 -0
  296. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/index.jsx +1 -0
  297. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/mock.stories.js +1 -0
  298. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/styles.js +1 -0
  299. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/demo.stories.jsx +3 -0
  300. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/index.jsx +1 -0
  301. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/mock.stories.js +2 -0
  302. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/styles.js +1 -0
  303. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/demo.stories.jsx +3 -0
  304. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/index.jsx +1 -0
  305. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/mock.stories.js +2 -0
  306. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/styles.js +1 -0
  307. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/demo.stories.jsx +3 -0
  308. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/index.jsx +1 -0
  309. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/mock.stories.js +2 -0
  310. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/styles.js +1 -0
  311. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/demo.stories.jsx +3 -0
  312. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/index.jsx +1 -0
  313. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/mock.stories.js +2 -0
  314. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/styles.js +1 -0
  315. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/demo.stories.jsx +3 -0
  316. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/index.jsx +1 -0
  317. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/mock.stories.js +2 -0
  318. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/styles.js +1 -0
  319. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/StatusWork.jsx +1 -0
  320. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/demo.stories.jsx +3 -0
  321. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/index.jsx +1 -0
  322. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/mock.stories.js +2 -0
  323. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/styles.js +1 -0
  324. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/demo.stories.jsx +3 -0
  325. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/index.jsx +1 -0
  326. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/mock.stories.js +2 -0
  327. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/styles.js +1 -0
  328. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/time-of-day.js +1 -0
  329. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/StatusWork.jsx +1 -0
  330. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +2 -0
  331. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.jsx +1 -0
  332. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/mock.stories.js +2 -0
  333. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/styles.js +1 -0
  334. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +2 -0
  335. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.jsx +1 -0
  336. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/mock.stories.js +2 -0
  337. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/styles.js +1 -0
  338. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/demo.stories.jsx +3 -0
  339. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/index.jsx +1 -0
  340. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/mock.stories.js +2 -0
  341. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/styles.js +1 -0
  342. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/text-url.jsx +1 -0
  343. package/src/auth.js +0 -637
package/src/auth.js DELETED
@@ -1,637 +0,0 @@
1
- class PegaAuth {
2
- constructor(ssKeyConfig) {
3
- if (typeof ssKeyConfig === 'string') {
4
- this.ssKeyConfig = ssKeyConfig;
5
- this.#reloadConfig();
6
- } else {
7
- // object with config structure is passed in
8
- this.config = ssKeyConfig;
9
- }
10
- this.urlencoded = 'application/x-www-form-urlencoded';
11
- this.isNode = typeof window === 'undefined';
12
-
13
- // For isNode path the below attributes are initialized on first method invocation
14
- if (!this.isNode) {
15
- this.crypto = window.crypto;
16
- this.subtle = window.crypto.subtle;
17
- }
18
- if (!this.config.serverType) {
19
- this.config.serverType = 'infinity';
20
- }
21
- }
22
-
23
- #reloadConfig() {
24
- if (!this.ssKeyConfig) {
25
- return;
26
- }
27
- const peConfig = window.sessionStorage.getItem(this.ssKeyConfig);
28
- let obj = {};
29
- if (peConfig) {
30
- try {
31
- obj = JSON.parse(peConfig);
32
- } catch (e) {
33
- try {
34
- obj = JSON.parse(atob(peConfig));
35
- } catch (err) {
36
- obj = {};
37
- }
38
- }
39
- }
40
- this.config = peConfig ? obj : {};
41
- }
42
-
43
- #updateConfig() {
44
- if (this.ssKeyConfig) {
45
- window.sessionStorage.setItem(this.ssKeyConfig, btoa(JSON.stringify(this.config)));
46
- }
47
- }
48
-
49
- async #importSingleLib(libName, libProp) {
50
- return import(libName)
51
- .then((mod) => {
52
- this[libProp] = mod.default;
53
- })
54
- .catch((e) => {
55
- console.error(`Library ${libName} failed to load`);
56
- });
57
- }
58
-
59
- async #importNodeLibs() {
60
- // Also current assumption is using Node 18 or better
61
- return Promise.all([
62
- this.#importSingleLib('node-fetch', 'fetch'),
63
- this.#importSingleLib('open', 'open'),
64
- this.#importSingleLib('node:crypto', 'crypto'),
65
- this.#importSingleLib('node:https', 'https'),
66
- this.#importSingleLib('node:http', 'http'),
67
- this.#importSingleLib('node:fs', 'fs')
68
- ]).then(() => {
69
- this.subtle = this.crypto.subtle || this.crypto.webcrypto.subtle;
70
- /* eslint-disable-next-line no-global-assign */
71
- fetch = this.fetch;
72
- });
73
- }
74
-
75
- // For PKCE the authorize includes a code_challenge & code_challenge_method as well
76
- async #buildAuthorizeUrl(state) {
77
- const {
78
- serverType,
79
- clientId,
80
- redirectUri,
81
- authorizeUri,
82
- authService,
83
- sessionIndex,
84
- appAlias,
85
- userIdentifier,
86
- password,
87
- noPKCE,
88
- isolationId
89
- } = this.config;
90
- const bInfinity = serverType === 'infinity';
91
-
92
- if (!noPKCE) {
93
- // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars
94
- const buf = new Uint8Array(64);
95
- this.crypto.getRandomValues(buf);
96
- this.config.codeVerifier = this.#base64UrlSafeEncode(buf);
97
- }
98
-
99
- // If sessionIndex exists then increment attempts count (we will stop sending session_index after two failures)
100
- if (sessionIndex) {
101
- this.config.sessionIndexAttempts += 1;
102
- }
103
- // Persist codeVerifier in session storage so it survives the redirects that are to follow
104
- this.#updateConfig();
105
-
106
- if (!state) {
107
- // Calc random state variable
108
- const buf = new Uint8Array(32);
109
- this.crypto.getRandomValues(buf);
110
- state = this.#base64UrlSafeEncode(buf);
111
- }
112
-
113
- // Trim alias to include just the real alias piece
114
- const addtlScope = appAlias ? `+app.alias.${appAlias.replace(/^app\//, '')}` : '';
115
- const scope = bInfinity ? `openid${addtlScope}` : 'user_info';
116
-
117
- // Add explicit creds if specified to try to avoid login popup
118
- const authServiceArg = authService ? `&authentication_service=${encodeURIComponent(authService)}` : '';
119
- const sessionIndexArg =
120
- sessionIndex && this.config.sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : '';
121
- const userIdentifierArg = userIdentifier ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}` : '';
122
- const passwordArg = password && userIdentifier ? `&Password=${encodeURIComponent(atob(password))}` : '';
123
- const moreAuthArgs = bInfinity
124
- ? `&enable_psyncid=true${authServiceArg}${sessionIndexArg}${userIdentifierArg}${passwordArg}`
125
- : `&isolationID=${isolationId}`;
126
-
127
- let pkceArgs = '';
128
- if (!noPKCE) {
129
- const cc = await this.#getCodeChallenge(this.config.codeVerifier);
130
- pkceArgs = `&code_challenge=${cc}&code_challenge_method=S256`;
131
- }
132
- return `${authorizeUri}?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&scope=${scope}&state=${state}${pkceArgs}${moreAuthArgs}`;
133
- }
134
-
135
- async login() {
136
- if (this.isNode && !this.crypto) {
137
- // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
138
- await this.#importNodeLibs();
139
- }
140
- const { grantType, noPKCE } = this.config;
141
- if (grantType && grantType !== 'authCode') {
142
- return this.getToken();
143
- }
144
- // Make sure browser in a secure context, else PKCE will fail
145
- if (!this.isNode && !noPKCE && !window.isSecureContext) {
146
- throw (new Error(`Authorization code grant flow failed due to insecure browser context at ${window.location.origin}. Use localhost or https.`));
147
- }
148
- return this.#authCodeStart();
149
- }
150
-
151
- // authCode login issues the authorize endpoint transaction and deals with redirects
152
- /* eslint-disable-next-line sonarjs/cognitive-complexity */
153
- async #authCodeStart() {
154
- const fnGetRedirectUriOrigin = () => {
155
- const redirectUri = this.config.redirectUri;
156
- const nRootOffset = redirectUri.indexOf('//');
157
- const nFirstPathOffset = nRootOffset !== -1 ? redirectUri.indexOf('/', nRootOffset + 2) : -1;
158
- return nFirstPathOffset !== -1 ? redirectUri.substring(0, nFirstPathOffset) : redirectUri;
159
- };
160
-
161
- const redirectOrigin = fnGetRedirectUriOrigin();
162
- const state = this.isNode ? '' : btoa(window.location.origin);
163
-
164
- return new Promise((resolve, reject) => {
165
- this.#buildAuthorizeUrl(state).then((url) => {
166
- let myWindow = null; // popup or iframe
167
- let elIframe = null;
168
- let elCloseBtn = null;
169
- const iframeTimeout = this.config.silentTimeout !== undefined ? this.config.silentTimeout : 5000;
170
- let bWinIframe =
171
- !this.isNode &&
172
- iframeTimeout > 0 &&
173
- ((!!this.config.userIdentifier && !!this.config.password) ||
174
- this.config.iframeLoginUI ||
175
- this.config.authService !== 'pega');
176
- let tmrAuthComplete = null;
177
- let checkWindowClosed = null;
178
- const myWinOnLoad = () => {
179
- try {
180
- if (bWinIframe) {
181
- elIframe.contentWindow.postMessage({ type: 'PegaAuth' }, redirectOrigin);
182
- } else {
183
- myWindow.postMessage({ type: 'PegaAuth' }, redirectOrigin);
184
- }
185
- } catch (e) {
186
- // Exception trying to postMessage on load (perhaps should console.warn)
187
- }
188
- };
189
- /* eslint-disable prefer-promise-reject-errors */
190
- const fnOpenPopup = () => {
191
- if (this.config.noPopups) {
192
- return reject('no-popups');
193
- }
194
- myWindow = (this.isNode ? this.open : window.open)(url, '_blank', 'width=700,height=500,left=200,top=100');
195
- if (!myWindow) {
196
- // Blocked by popup-blocker
197
- return reject('blocked');
198
- }
199
- checkWindowClosed = setInterval(() => {
200
- if (myWindow.closed) {
201
- clearInterval(checkWindowClosed);
202
- reject('closed');
203
- }
204
- }, 500);
205
- if (!this.isNode) {
206
- try {
207
- myWindow.addEventListener('load', myWinOnLoad, true);
208
- } catch (e) {
209
- // Exception trying to add onload handler to opened window
210
- console.error(`Error adding event listener on popup window: ${e}`);
211
- }
212
- }
213
- };
214
- /* eslint-enable prefer-promise-reject-errors */
215
- const fnCloseIframe = () => {
216
- elIframe.parentNode.removeChild(elIframe);
217
- elCloseBtn.parentNode.removeChild(elCloseBtn);
218
- elIframe = null;
219
- elCloseBtn = null;
220
- bWinIframe = false;
221
- };
222
- const fnCloseAndReject = () => {
223
- fnCloseIframe();
224
- /* eslint-disable-next-line prefer-promise-reject-errors */
225
- reject('closed');
226
- };
227
- let authMessageReceiver = null;
228
- /* Retrieve token(s) and close login window */
229
- const fnGetTokenAndFinish = (code) => {
230
- if (!this.isNode) {
231
- window.removeEventListener('message', authMessageReceiver, false);
232
- }
233
- this.getToken(code)
234
- .then((token) => {
235
- if (bWinIframe) {
236
- clearTimeout(tmrAuthComplete);
237
- fnCloseIframe();
238
- } else if (!this.isNode) {
239
- clearInterval(checkWindowClosed);
240
- myWindow.close();
241
- }
242
- resolve(token);
243
- })
244
- .catch((e) => {
245
- reject(e);
246
- });
247
- };
248
- // If there is a userIdentifier and password specified or an external SSO auth service,
249
- // we can try to use this silently in an iFrame first
250
- if (bWinIframe) {
251
- const nFrameZLevel = 99999;
252
- elIframe = document.createElement('iframe');
253
- elIframe.id = `pe${this.config.clientId}`;
254
- const loginBoxWidth = 500;
255
- const loginBoxHeight = 700;
256
- const oStyle = elIframe.style;
257
- oStyle.position = 'absolute';
258
- oStyle.display = 'none';
259
- oStyle.zIndex = nFrameZLevel;
260
- oStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2)}px`;
261
- oStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2)}px`;
262
- oStyle.width = '500px';
263
- oStyle.height = '700px';
264
- // Add Iframe to top of document DOM to have it load
265
- document.body.insertBefore(elIframe, document.body.firstChild);
266
- // document.getElementsByTagName('body')[0].appendChild(elIframe);
267
- elIframe.addEventListener('load', myWinOnLoad, true);
268
- // Disallow iframe content attempts to navigate main window
269
- elIframe.setAttribute('sandbox', 'allow-scripts allow-forms allow-same-origin');
270
- // Adding prompt=none as this is standard OIDC way to communicate no UI is expected (expecting Pega security to support this one day)
271
- elIframe.setAttribute('src', `${url}&prompt=none`);
272
-
273
- const svgCloseBtn = `<?xml version="1.0" encoding="UTF-8"?>
274
- <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">
275
- <title>Dismiss - Black</title>
276
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
277
- <g transform="translate(1.000000, 1.000000)">
278
- <circle fill="#252C32" cx="16" cy="16" r="16"></circle>
279
- <g transform="translate(9.109375, 9.214844)" fill="#FFFFFF" fill-rule="nonzero">
280
- <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>
281
- </g>
282
- </g>
283
- </g>
284
- </svg>`;
285
- const bCloseWithinFrame = false;
286
- elCloseBtn = document.createElement('img');
287
- elCloseBtn.onclick = fnCloseAndReject;
288
- elCloseBtn.src = `data:image/svg+xml;base64,${btoa(svgCloseBtn)}`;
289
- const oBtnStyle = elCloseBtn.style;
290
- oBtnStyle.cursor = 'pointer';
291
- // If svg doesn't set width and height might want to set oBtStyle width and height to something like '2em'
292
- oBtnStyle.position = 'absolute';
293
- oBtnStyle.display = 'none';
294
- oBtnStyle.zIndex = nFrameZLevel + 1;
295
- const nTopOffset = bCloseWithinFrame ? 5 : -10;
296
- const nRightOffset = bCloseWithinFrame ? -34 : -20;
297
- const nTop = Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2) + nTopOffset;
298
- oBtnStyle.top = `${nTop}px`;
299
- const nLeft = Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2) + loginBoxWidth + nRightOffset;
300
- oBtnStyle.left = `${nLeft}px`;
301
- document.body.insertBefore(elCloseBtn, document.body.firstChild);
302
- // If the password was wrong, then the login screen will be in the iframe
303
- // ..and with Pega without realization of US-372314 it may replace the top (main portal) window
304
- // For now set a timer and if the timer expires, remove the iFrame and use same url within
305
- // visible window
306
- tmrAuthComplete = setTimeout(() => {
307
- clearTimeout(tmrAuthComplete);
308
- // remove password from config
309
- if (this.config.password) {
310
- delete this.config.password;
311
- this.#updateConfig();
312
- }
313
- // Display the iframe where the redirects did not succeed (or invoke a popup window)
314
- if (this.config.iframeLoginUI) {
315
- elIframe.style.display = 'block';
316
- elCloseBtn.style.display = 'block';
317
- } else {
318
- fnCloseIframe();
319
- fnOpenPopup();
320
- }
321
- }, iframeTimeout);
322
- } else {
323
- if (this.isNode) {
324
- // Determine port to listen to by extracting it from redirect uri
325
- const { redirectUri, cert, key } = this.config;
326
- const isHttp = redirectUri.startsWith('http:');
327
- const nLocalhost = redirectUri.indexOf('localhost:');
328
- const nSlash = redirectUri.indexOf('/', nLocalhost + 10);
329
- const nPort = parseInt(redirectUri.substring(nLocalhost + 10, nSlash), 10);
330
- if (nLocalhost !== -1) {
331
- const options =
332
- key && cert && !isHttp
333
- ? {
334
- key: this.fs.readFileSync(key),
335
- cert: this.fs.readFileSync(cert)
336
- }
337
- : {};
338
- const server = (isHttp ? this.http : this.https).createServer(options, (req, res) => {
339
- const { winTitle, winBodyHtml } = this.config;
340
- res.writeHead(200, { 'Content-Type': 'text/html' });
341
- // Auto closing window for now. Can always leave it up and allow authConfig props to set title and bodyHtml
342
- res.end(
343
- `<html><head><title>${winTitle}</title><script>window.close();</script></head><body>${winBodyHtml}</body></html>`
344
- );
345
- const queryString = req.url.split('?')[1];
346
- const urlParams = new URLSearchParams(queryString);
347
- const code = urlParams.get('code');
348
- if (code) {
349
- // Stop receiving connections and close when all are handled.
350
- server.close();
351
- fnGetTokenAndFinish(code);
352
- }
353
- });
354
- /* eslint-enable no-undef */
355
- server.listen(nPort);
356
- }
357
- }
358
- fnOpenPopup();
359
- }
360
-
361
- if (!this.isNode) {
362
- /* Handler to receive the auth code */
363
- authMessageReceiver = (event) => {
364
- // Check origin to make sure it is the redirect origin
365
- if (event.origin !== redirectOrigin) return;
366
- if (!event.data || !event.data.type || event.data.type !== 'PegaAuth') return;
367
- const code = event.data.code.toString();
368
- fnGetTokenAndFinish(code);
369
- };
370
- window.addEventListener('message', authMessageReceiver, false);
371
- window.authCodeCallback = (code) => {
372
- fnGetTokenAndFinish(code);
373
- };
374
- }
375
- });
376
- });
377
- }
378
-
379
- // For PKCE token endpoint includes code_verifier
380
- /* eslint-disable-next-line sonarjs/cognitive-complexity */
381
- getToken(authCode) {
382
- // Reload config to pick up the previously stored codeVerifier
383
- this.#reloadConfig();
384
-
385
- const {
386
- serverType,
387
- isolationId,
388
- clientId,
389
- clientSecret,
390
- redirectUri,
391
- tokenUri,
392
- codeVerifier,
393
- grantType,
394
- sessionIndex,
395
- customTokenParams,
396
- userIdentifier,
397
- password,
398
- noPKCE
399
- } = this.config;
400
-
401
- const bAuthCode = !grantType || grantType === 'authCode';
402
- if (bAuthCode && !authCode && !this.isNode) {
403
- const queryString = window.location.search;
404
- const urlParams = new URLSearchParams(queryString);
405
- authCode = urlParams.get('code');
406
- }
407
-
408
- const formData = new URLSearchParams();
409
- formData.append('client_id', clientId);
410
- if (clientSecret) {
411
- formData.append('client_secret', clientSecret);
412
- }
413
- /* eslint-disable camelcase */
414
- const fullGTName = {
415
- authCode: 'authorization_code',
416
- clientCreds: 'client_credentials',
417
- customBearer: 'custom-bearer',
418
- passwordCreds: 'password'
419
- }[grantType];
420
- const grant_type = fullGTName || grantType || 'authorization_code';
421
- formData.append('grant_type', grant_type);
422
- if (serverType === 'launchpad' && grantType !== 'authCode') {
423
- formData.append('isolation_ids', isolationId);
424
- }
425
- if (bAuthCode) {
426
- formData.append('code', authCode);
427
- formData.append('redirect_uri', redirectUri);
428
- if (!noPKCE) {
429
- formData.append('code_verifier', codeVerifier);
430
- }
431
- } else if (sessionIndex) {
432
- formData.append('session_index', sessionIndex);
433
- }
434
- /* eslint-enable camelcase */
435
- if (grantType === 'customBearer' && customTokenParams) {
436
- Object.keys(customTokenParams).forEach((param) => {
437
- formData.append(param, customTokenParams[param]);
438
- });
439
- }
440
- if (grantType !== 'authCode') {
441
- formData.append('enable_psyncId', 'true');
442
- }
443
- if (grantType === 'passwordCreds') {
444
- formData.append('username', userIdentifier);
445
- formData.append('password', atob(password));
446
- }
447
-
448
- return fetch(tokenUri, {
449
- agent: this.#getAgent(),
450
- method: 'POST',
451
- headers: new Headers({
452
- 'content-type': this.urlencoded
453
- }),
454
-
455
- body: formData.toString()
456
- })
457
- .then((response) => response.json())
458
- .then((token) => {
459
- if (token.errors || token.error) {
460
- console.error(`Token endpoint error: ${JSON.stringify(token.errors || token.error)}`);
461
- } else {
462
- // .expires_in contains the # of seconds before access token expires
463
- // add property to keep track of current time when the token expires
464
- token.eA = Date.now() + token.expires_in * 1000;
465
- if (this.config.codeVerifier) {
466
- delete this.config.codeVerifier;
467
- }
468
- // If there is a session_index then move this to the peConfig structure (as used on authorize)
469
- if (token.session_index) {
470
- this.config.sessionIndex = token.session_index;
471
- }
472
- // If we got a token and have a session index, then reset the sessionIndexAttempts
473
- if (this.config.sessionIndex) {
474
- this.config.sessionIndexAttempts = 0;
475
- }
476
- this.#updateConfig();
477
- }
478
- return token;
479
- })
480
- .catch((e) => {
481
- console.error(`Token endpoint error: ${e}`);
482
- });
483
- }
484
-
485
- /* eslint-disable camelcase */
486
- async refreshToken(refresh_token) {
487
- const { clientId, clientSecret, tokenUri } = this.config;
488
-
489
- if (this.isNode && !this.crypto) {
490
- // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
491
- await this.#importNodeLibs();
492
- }
493
-
494
- const formData = new URLSearchParams();
495
- formData.append('client_id', clientId);
496
- if (clientSecret) {
497
- formData.append('client_secret', clientSecret);
498
- }
499
- formData.append('grant_type', 'refresh_token');
500
- formData.append('refresh_token', refresh_token);
501
-
502
- return fetch(tokenUri, {
503
- agent: this.#getAgent(),
504
- method: 'POST',
505
- headers: new Headers({
506
- 'content-type': this.urlencoded
507
- }),
508
-
509
- body: formData.toString()
510
- })
511
- .then((response) => {
512
- if (!response.ok && response.status === 401) {
513
- return null;
514
- }
515
- return response.json();
516
- })
517
- .then((token) => {
518
- if (token) {
519
- // .expires_in contains the # of seconds before access token expires
520
- // add property to keep track of current time when the token expires
521
- token.eA = Date.now() + token.expires_in * 1000;
522
- }
523
- return token;
524
- })
525
- .catch((e) => {
526
- console.warn(`Refresh token failed: ${e}`);
527
- });
528
- }
529
-
530
- async revokeTokens(access_token, refresh_token = null) {
531
- if (Object.keys(this.config).length === 0) {
532
- // Must have a config structure to proceed
533
- return;
534
- }
535
- const { clientId, clientSecret, revokeUri } = this.config;
536
-
537
- if (this.isNode && !this.crypto) {
538
- // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor
539
- await this.#importNodeLibs();
540
- }
541
-
542
- const hdrs = { 'content-type': this.urlencoded };
543
- if (clientSecret) {
544
- const basicCreds = btoa(`${clientId}:${clientSecret}`);
545
- hdrs.authorization = `Basic ${basicCreds}`;
546
- }
547
- const aTknProps = ['access_token'];
548
- if (refresh_token) {
549
- aTknProps.push('refresh_token');
550
- }
551
- aTknProps.forEach((prop) => {
552
- const formData = new URLSearchParams();
553
- if (!clientSecret) {
554
- formData.append('client_id', clientId);
555
- }
556
- formData.append('token', prop === 'access_token' ? access_token : refresh_token);
557
- formData.append('token_type_hint', prop);
558
- fetch(revokeUri, {
559
- agent: this.#getAgent(),
560
- method: 'POST',
561
- headers: new Headers(hdrs),
562
- body: formData.toString()
563
- })
564
- .then((response) => {
565
- if (!response.ok) {
566
- console.error(`Error revoking ${prop}:${response.status}`);
567
- }
568
- })
569
- .catch((e) => {
570
- console.error(`Error revoking ${prop}`);
571
- });
572
- });
573
- // Also clobber any sessionIndex
574
- if (this.config.sessionIndex) {
575
- delete this.config.sessionIndex;
576
- this.#updateConfig();
577
- }
578
- }
579
- /* eslint-enable camelcase */
580
-
581
- #sha256Hash(str) {
582
- // Found that the Node implementation of subtle.digest is yielding incorrect results
583
- // so using a different set of apis to get expected results.
584
- if (this.isNode) {
585
- return new Promise((resolve) => {
586
- return resolve(this.crypto.createHash('sha256').update(str).digest());
587
- });
588
- }
589
- return this.subtle.digest('SHA-256', new TextEncoder().encode(str));
590
- }
591
-
592
- // Base64 encode
593
- #encode64(buff) {
594
- return btoa(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));
595
- }
596
-
597
- /*
598
- * Base64 url safe encoding of an array
599
- */
600
- #base64UrlSafeEncode(buf) {
601
- return this.#encode64(buf).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
602
- }
603
-
604
- /* Calc code verifier if necessary
605
- */
606
- /* eslint-disable camelcase */
607
- async #getCodeChallenge(code_verifier) {
608
- return this.#sha256Hash(code_verifier)
609
- .then((hashed) => {
610
- return this.#base64UrlSafeEncode(hashed);
611
- })
612
- .catch((error) => {
613
- console.error(`Error calculation code challenge for PKCE: ${error}`);
614
- })
615
- .finally(() => {
616
- return null;
617
- });
618
- }
619
- /* eslint-enable camelcase */
620
-
621
- /*
622
- * Return agent value for POST commands
623
- */
624
- #getAgent() {
625
- if (this.isNode && this.config.ignoreInvalidCerts) {
626
- let options = {rejectUnauthorized: false};
627
- if (this.config.legacyTLS) {
628
- options.secureOptions = this.crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT;
629
- }
630
- return new this.https.Agent(options);
631
- } else {
632
- return undefined;
633
- }
634
- }
635
- }
636
-
637
- export default PegaAuth;