@keycloakify/login-ui 250004.0.33

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 (387) hide show
  1. package/KcContext/getKcContextMock.d.ts +1 -0
  2. package/KcContext/getKcContextMock.js +1 -0
  3. package/KcContext/index.d.ts +2 -0
  4. package/KcContext/index.js +2 -0
  5. package/KcContext/useKcContext.d.ts +10 -0
  6. package/KcContext/useKcContext.js +17 -0
  7. package/README.md +12 -0
  8. package/core/KcContext/KcContext.d.ts +605 -0
  9. package/core/KcContext/KcContext.js +43 -0
  10. package/core/KcContext/getKcContextMock.d.ts +23 -0
  11. package/core/KcContext/getKcContextMock.js +27 -0
  12. package/core/KcContext/kcContextMocks.d.ts +4 -0
  13. package/core/KcContext/kcContextMocks.js +345 -0
  14. package/core/getKcClsx.d.ts +11 -0
  15. package/core/getKcClsx.js +54 -0
  16. package/core/i18n/GenericI18n.d.ts +63 -0
  17. package/core/i18n/GenericI18n.js +1 -0
  18. package/core/i18n/getI18n.d.ts +45 -0
  19. package/core/i18n/getI18n.js +246 -0
  20. package/core/i18n/i18nBuilder.d.ts +18 -0
  21. package/core/i18n/i18nBuilder.js +26 -0
  22. package/core/i18n/messages_defaultSet/ar.d.ts +447 -0
  23. package/core/i18n/messages_defaultSet/ar.js +451 -0
  24. package/core/i18n/messages_defaultSet/ca.d.ts +443 -0
  25. package/core/i18n/messages_defaultSet/ca.js +447 -0
  26. package/core/i18n/messages_defaultSet/cs.d.ts +445 -0
  27. package/core/i18n/messages_defaultSet/cs.js +449 -0
  28. package/core/i18n/messages_defaultSet/da.d.ts +317 -0
  29. package/core/i18n/messages_defaultSet/da.js +321 -0
  30. package/core/i18n/messages_defaultSet/de.d.ts +459 -0
  31. package/core/i18n/messages_defaultSet/de.js +463 -0
  32. package/core/i18n/messages_defaultSet/el.d.ts +438 -0
  33. package/core/i18n/messages_defaultSet/el.js +442 -0
  34. package/core/i18n/messages_defaultSet/en.d.ts +470 -0
  35. package/core/i18n/messages_defaultSet/en.js +474 -0
  36. package/core/i18n/messages_defaultSet/es.d.ts +452 -0
  37. package/core/i18n/messages_defaultSet/es.js +456 -0
  38. package/core/i18n/messages_defaultSet/fa.d.ts +438 -0
  39. package/core/i18n/messages_defaultSet/fa.js +442 -0
  40. package/core/i18n/messages_defaultSet/fi.d.ts +377 -0
  41. package/core/i18n/messages_defaultSet/fi.js +381 -0
  42. package/core/i18n/messages_defaultSet/fr.d.ts +393 -0
  43. package/core/i18n/messages_defaultSet/fr.js +397 -0
  44. package/core/i18n/messages_defaultSet/hu.d.ts +443 -0
  45. package/core/i18n/messages_defaultSet/hu.js +447 -0
  46. package/core/i18n/messages_defaultSet/index.d.ts +3086 -0
  47. package/core/i18n/messages_defaultSet/index.js +72 -0
  48. package/core/i18n/messages_defaultSet/it.d.ts +318 -0
  49. package/core/i18n/messages_defaultSet/it.js +322 -0
  50. package/core/i18n/messages_defaultSet/ja.d.ts +323 -0
  51. package/core/i18n/messages_defaultSet/ja.js +327 -0
  52. package/core/i18n/messages_defaultSet/ka.d.ts +468 -0
  53. package/core/i18n/messages_defaultSet/ka.js +472 -0
  54. package/core/i18n/messages_defaultSet/lt.d.ts +203 -0
  55. package/core/i18n/messages_defaultSet/lt.js +207 -0
  56. package/core/i18n/messages_defaultSet/lv.d.ts +214 -0
  57. package/core/i18n/messages_defaultSet/lv.js +218 -0
  58. package/core/i18n/messages_defaultSet/nl.d.ts +285 -0
  59. package/core/i18n/messages_defaultSet/nl.js +289 -0
  60. package/core/i18n/messages_defaultSet/no.d.ts +202 -0
  61. package/core/i18n/messages_defaultSet/no.js +206 -0
  62. package/core/i18n/messages_defaultSet/pl.d.ts +292 -0
  63. package/core/i18n/messages_defaultSet/pl.js +296 -0
  64. package/core/i18n/messages_defaultSet/pt-BR.d.ts +347 -0
  65. package/core/i18n/messages_defaultSet/pt-BR.js +351 -0
  66. package/core/i18n/messages_defaultSet/pt.d.ts +448 -0
  67. package/core/i18n/messages_defaultSet/pt.js +452 -0
  68. package/core/i18n/messages_defaultSet/ru.d.ts +220 -0
  69. package/core/i18n/messages_defaultSet/ru.js +224 -0
  70. package/core/i18n/messages_defaultSet/sk.d.ts +448 -0
  71. package/core/i18n/messages_defaultSet/sk.js +452 -0
  72. package/core/i18n/messages_defaultSet/sv.d.ts +201 -0
  73. package/core/i18n/messages_defaultSet/sv.js +205 -0
  74. package/core/i18n/messages_defaultSet/th.d.ts +443 -0
  75. package/core/i18n/messages_defaultSet/th.js +447 -0
  76. package/core/i18n/messages_defaultSet/tr.d.ts +270 -0
  77. package/core/i18n/messages_defaultSet/tr.js +274 -0
  78. package/core/i18n/messages_defaultSet/types.d.ts +3 -0
  79. package/core/i18n/messages_defaultSet/types.js +32 -0
  80. package/core/i18n/messages_defaultSet/uk.d.ts +442 -0
  81. package/core/i18n/messages_defaultSet/uk.js +446 -0
  82. package/core/i18n/messages_defaultSet/zh-CN.d.ts +447 -0
  83. package/core/i18n/messages_defaultSet/zh-CN.js +451 -0
  84. package/core/i18n/messages_defaultSet/zh-TW.d.ts +453 -0
  85. package/core/i18n/messages_defaultSet/zh-TW.js +457 -0
  86. package/core/kcClsx.d.ts +8 -0
  87. package/core/kcClsx.js +128 -0
  88. package/core/kcSanitize/HtmlPolicyBuilder.d.ts +27 -0
  89. package/core/kcSanitize/HtmlPolicyBuilder.js +207 -0
  90. package/core/kcSanitize/KcSanitizer.d.ts +11 -0
  91. package/core/kcSanitize/KcSanitizer.js +45 -0
  92. package/core/kcSanitize/KcSanitizerPolicy.d.ts +23 -0
  93. package/core/kcSanitize/KcSanitizerPolicy.js +148 -0
  94. package/core/kcSanitize/index.d.ts +1 -0
  95. package/core/kcSanitize/index.js +4 -0
  96. package/core/userProfileApi/index.d.ts +1 -0
  97. package/core/userProfileApi/index.js +1 -0
  98. package/core/userProfileApi/kcNumberUnFormat.d.ts +2 -0
  99. package/core/userProfileApi/kcNumberUnFormat.js +83 -0
  100. package/core/userProfileApi/userProfileApi.d.ts +83 -0
  101. package/core/userProfileApi/userProfileApi.js +1119 -0
  102. package/i18n/GenericI18n.d.ts +72 -0
  103. package/i18n/GenericI18n.js +4 -0
  104. package/i18n/i18nBuilder.d.ts +18 -0
  105. package/i18n/i18nBuilder.js +26 -0
  106. package/i18n/index.d.ts +3 -0
  107. package/i18n/index.js +1 -0
  108. package/i18n/useI18n.d.ts +28 -0
  109. package/i18n/useI18n.js +86 -0
  110. package/import.meta.env.BASE_URL.d.ts +5 -0
  111. package/import.meta.env.BASE_URL.js +41 -0
  112. package/kcSanitize.d.ts +1 -0
  113. package/kcSanitize.js +1 -0
  114. package/keycloak-theme/login/KcContext.ts +15 -0
  115. package/keycloak-theme/login/KcPage.tsx +47 -0
  116. package/keycloak-theme/login/components/LogoutOtherSessions.tsx +27 -0
  117. package/keycloak-theme/login/components/PasswordWrapper.tsx +38 -0
  118. package/keycloak-theme/login/components/Template/Template.tsx +235 -0
  119. package/keycloak-theme/login/components/Template/index.ts +1 -0
  120. package/keycloak-theme/login/components/Template/useInitializeTemplate.ts +60 -0
  121. package/keycloak-theme/login/components/UserProfileFormFields/AddRemoveButtonsMultiValuedAttribute.tsx +65 -0
  122. package/keycloak-theme/login/components/UserProfileFormFields/DO_MAKE_USER_CONFIRM_PASSWORD.ts +2 -0
  123. package/keycloak-theme/login/components/UserProfileFormFields/FieldErrors.tsx +37 -0
  124. package/keycloak-theme/login/components/UserProfileFormFields/GroupLabel.tsx +78 -0
  125. package/keycloak-theme/login/components/UserProfileFormFields/InputFieldByType.tsx +52 -0
  126. package/keycloak-theme/login/components/UserProfileFormFields/InputLabel.tsx +19 -0
  127. package/keycloak-theme/login/components/UserProfileFormFields/InputTag.tsx +130 -0
  128. package/keycloak-theme/login/components/UserProfileFormFields/InputTagSelects.tsx +118 -0
  129. package/keycloak-theme/login/components/UserProfileFormFields/SelectTag.tsx +86 -0
  130. package/keycloak-theme/login/components/UserProfileFormFields/TextareaTag.tsx +53 -0
  131. package/keycloak-theme/login/components/UserProfileFormFields/UserProfileFormFields.tsx +132 -0
  132. package/keycloak-theme/login/components/UserProfileFormFields/index.ts +1 -0
  133. package/keycloak-theme/login/i18n.ts +7 -0
  134. package/keycloak-theme/login/mocks/getKcContextMock.ts +18 -0
  135. package/keycloak-theme/login/pages/PageIndex.tsx +133 -0
  136. package/keycloak-theme/login/pages/code/Page.tsx +47 -0
  137. package/keycloak-theme/login/pages/code/index.ts +3 -0
  138. package/keycloak-theme/login/pages/delete-account-confirm/Page.tsx +59 -0
  139. package/keycloak-theme/login/pages/delete-account-confirm/index.ts +3 -0
  140. package/keycloak-theme/login/pages/delete-credential/Page.tsx +40 -0
  141. package/keycloak-theme/login/pages/delete-credential/index.ts +3 -0
  142. package/keycloak-theme/login/pages/error/Page.tsx +32 -0
  143. package/keycloak-theme/login/pages/error/index.ts +3 -0
  144. package/keycloak-theme/login/pages/frontchannel-logout/Page.tsx +40 -0
  145. package/keycloak-theme/login/pages/frontchannel-logout/index.ts +3 -0
  146. package/keycloak-theme/login/pages/idp-review-user-profile/Page.tsx +53 -0
  147. package/keycloak-theme/login/pages/idp-review-user-profile/index.ts +3 -0
  148. package/keycloak-theme/login/pages/info/Page.tsx +80 -0
  149. package/keycloak-theme/login/pages/info/index.ts +3 -0
  150. package/keycloak-theme/login/pages/login/Form.tsx +164 -0
  151. package/keycloak-theme/login/pages/login/Info.tsx +25 -0
  152. package/keycloak-theme/login/pages/login/Page.tsx +32 -0
  153. package/keycloak-theme/login/pages/login/SocialProviders.tsx +64 -0
  154. package/keycloak-theme/login/pages/login/index.ts +3 -0
  155. package/keycloak-theme/login/pages/login-config-totp/Page.tsx +219 -0
  156. package/keycloak-theme/login/pages/login-config-totp/index.ts +3 -0
  157. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.tsx +51 -0
  158. package/keycloak-theme/login/pages/login-idp-link-confirm/index.ts +3 -0
  159. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.tsx +41 -0
  160. package/keycloak-theme/login/pages/login-idp-link-confirm-override/index.ts +3 -0
  161. package/keycloak-theme/login/pages/login-idp-link-email/Page.tsx +32 -0
  162. package/keycloak-theme/login/pages/login-idp-link-email/index.ts +3 -0
  163. package/keycloak-theme/login/pages/login-oauth-grant/Page.tsx +120 -0
  164. package/keycloak-theme/login/pages/login-oauth-grant/index.ts +3 -0
  165. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.tsx +64 -0
  166. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/index.ts +3 -0
  167. package/keycloak-theme/login/pages/login-otp/Page.tsx +125 -0
  168. package/keycloak-theme/login/pages/login-otp/index.ts +3 -0
  169. package/keycloak-theme/login/pages/login-page-expired/Page.tsx +28 -0
  170. package/keycloak-theme/login/pages/login-page-expired/index.ts +3 -0
  171. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.tsx +233 -0
  172. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/index.ts +3 -0
  173. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/useScript.tsx +64 -0
  174. package/keycloak-theme/login/pages/login-password/Page.tsx +103 -0
  175. package/keycloak-theme/login/pages/login-password/index.ts +3 -0
  176. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.tsx +167 -0
  177. package/keycloak-theme/login/pages/login-recovery-authn-code-config/index.ts +3 -0
  178. package/keycloak-theme/login/pages/login-recovery-authn-code-config/useScript.tsx +145 -0
  179. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.tsx +84 -0
  180. package/keycloak-theme/login/pages/login-recovery-authn-code-input/index.ts +3 -0
  181. package/keycloak-theme/login/pages/login-reset-otp/Page.tsx +82 -0
  182. package/keycloak-theme/login/pages/login-reset-otp/index.ts +3 -0
  183. package/keycloak-theme/login/pages/login-reset-password/Form.tsx +78 -0
  184. package/keycloak-theme/login/pages/login-reset-password/Page.tsx +27 -0
  185. package/keycloak-theme/login/pages/login-reset-password/index.ts +3 -0
  186. package/keycloak-theme/login/pages/login-update-password/Page.tsx +132 -0
  187. package/keycloak-theme/login/pages/login-update-password/index.ts +3 -0
  188. package/keycloak-theme/login/pages/login-update-profile/Page.tsx +70 -0
  189. package/keycloak-theme/login/pages/login-update-profile/index.ts +3 -0
  190. package/keycloak-theme/login/pages/login-username/Page.tsx +176 -0
  191. package/keycloak-theme/login/pages/login-username/index.ts +3 -0
  192. package/keycloak-theme/login/pages/login-verify-email/Page.tsx +31 -0
  193. package/keycloak-theme/login/pages/login-verify-email/index.ts +3 -0
  194. package/keycloak-theme/login/pages/login-x509-info/Page.tsx +97 -0
  195. package/keycloak-theme/login/pages/login-x509-info/index.ts +3 -0
  196. package/keycloak-theme/login/pages/logout-confirm/Page.tsx +54 -0
  197. package/keycloak-theme/login/pages/logout-confirm/index.ts +3 -0
  198. package/keycloak-theme/login/pages/register/Form.tsx +102 -0
  199. package/keycloak-theme/login/pages/register/Page.tsx +26 -0
  200. package/keycloak-theme/login/pages/register/TermsAcceptance.tsx +54 -0
  201. package/keycloak-theme/login/pages/register/index.ts +3 -0
  202. package/keycloak-theme/login/pages/saml-post-form/Page.tsx +50 -0
  203. package/keycloak-theme/login/pages/saml-post-form/index.ts +3 -0
  204. package/keycloak-theme/login/pages/select-authenticator/Page.tsx +59 -0
  205. package/keycloak-theme/login/pages/select-authenticator/index.ts +3 -0
  206. package/keycloak-theme/login/pages/terms/Page.tsx +45 -0
  207. package/keycloak-theme/login/pages/terms/index.ts +3 -0
  208. package/keycloak-theme/login/pages/update-email/Page.tsx +74 -0
  209. package/keycloak-theme/login/pages/update-email/index.ts +3 -0
  210. package/keycloak-theme/login/pages/webauthn-authenticate/Page.tsx +190 -0
  211. package/keycloak-theme/login/pages/webauthn-authenticate/index.ts +3 -0
  212. package/keycloak-theme/login/pages/webauthn-authenticate/useScript.tsx +56 -0
  213. package/keycloak-theme/login/pages/webauthn-error/Page.tsx +74 -0
  214. package/keycloak-theme/login/pages/webauthn-error/index.ts +3 -0
  215. package/keycloak-theme/login/pages/webauthn-register/Page.tsx +83 -0
  216. package/keycloak-theme/login/pages/webauthn-register/index.ts +3 -0
  217. package/keycloak-theme/login/pages/webauthn-register/useScript.tsx +64 -0
  218. package/keycloak-theme/login/styleLevelCustomization.tsx +17 -0
  219. package/keycloak-theme/public/login/css/login.css +629 -0
  220. package/keycloak-theme/public/login/img/feedback-error-arrow-down.png +0 -0
  221. package/keycloak-theme/public/login/img/feedback-error-sign.png +0 -0
  222. package/keycloak-theme/public/login/img/feedback-success-arrow-down.png +0 -0
  223. package/keycloak-theme/public/login/img/feedback-success-sign.png +0 -0
  224. package/keycloak-theme/public/login/img/feedback-warning-arrow-down.png +0 -0
  225. package/keycloak-theme/public/login/img/feedback-warning-sign.png +0 -0
  226. package/keycloak-theme/public/login/img/keycloak-bg.png +0 -0
  227. package/keycloak-theme/public/login/img/keycloak-logo-text.png +0 -0
  228. package/keycloak-theme/public/login/img/keycloak-logo.png +0 -0
  229. package/keycloak-theme/public/login/js/authChecker.js +49 -0
  230. package/keycloak-theme/public/login/js/common.js +48 -0
  231. package/keycloak-theme/public/login/js/kcMultivalued.js +106 -0
  232. package/keycloak-theme/public/login/js/kcNumberFormat.js +21 -0
  233. package/keycloak-theme/public/login/js/kcNumberUnFormat.js +19 -0
  234. package/keycloak-theme/public/login/js/menu-button-links.js +315 -0
  235. package/keycloak-theme/public/login/js/passkeysConditionalAuth.js +79 -0
  236. package/keycloak-theme/public/login/js/passwordVisibility.js +15 -0
  237. package/keycloak-theme/public/login/js/userProfile.js +71 -0
  238. package/keycloak-theme/public/login/js/webauthnAuthenticate.js +82 -0
  239. package/keycloak-theme/public/login/js/webauthnRegister.js +140 -0
  240. package/keycloak-theme/public/login/resources-common/img/favicon.ico +0 -0
  241. package/keycloak-theme/public/login/resources-common/lib/pficon/pficon.css +22 -0
  242. package/keycloak-theme/public/login/resources-common/lib/pficon/pficon.woff2 +0 -0
  243. package/keycloak-theme/public/login/resources-common/node_modules/@patternfly/patternfly/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.woff +0 -0
  244. package/keycloak-theme/public/login/resources-common/node_modules/@patternfly/patternfly/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.woff2 +0 -0
  245. package/keycloak-theme/public/login/resources-common/node_modules/@patternfly/patternfly/assets/fonts/overpass-webfont/overpass-bold.woff +0 -0
  246. package/keycloak-theme/public/login/resources-common/node_modules/@patternfly/patternfly/assets/fonts/overpass-webfont/overpass-bold.woff2 +0 -0
  247. package/keycloak-theme/public/login/resources-common/node_modules/@patternfly/patternfly/patternfly.min.css +2 -0
  248. package/keycloak-theme/public/login/resources-common/node_modules/jquery/dist/jquery.min.js +2 -0
  249. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  250. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  251. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.ttf +0 -0
  252. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff +0 -0
  253. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  254. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  255. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  256. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  257. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  258. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  259. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-SemiboldItalic-webfont.woff2 +0 -0
  260. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  261. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  262. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/fonts/fontawesome-webfont.woff2 +0 -0
  263. package/keycloak-theme/public/login/resources-common/node_modules/patternfly/dist/img/bg-login.jpg +0 -0
  264. package/keycloak-theme/public/login/resources-common/node_modules/rfc4648/lib/rfc4648.js +178 -0
  265. package/package.json +19 -0
  266. package/src/KcContext/getKcContextMock.ts +1 -0
  267. package/src/KcContext/index.ts +10 -0
  268. package/src/KcContext/useKcContext.tsx +23 -0
  269. package/src/core/KcContext/KcContext.ts +819 -0
  270. package/src/core/KcContext/getKcContextMock.ts +63 -0
  271. package/src/core/KcContext/kcContextMocks.ts +623 -0
  272. package/src/core/getKcClsx.ts +87 -0
  273. package/src/core/i18n/GenericI18n.ts +64 -0
  274. package/src/core/i18n/getI18n.tsx +427 -0
  275. package/src/core/i18n/i18nBuilder.ts +101 -0
  276. package/src/core/i18n/messages_defaultSet/ar.ts +485 -0
  277. package/src/core/i18n/messages_defaultSet/ca.ts +517 -0
  278. package/src/core/i18n/messages_defaultSet/cs.ts +494 -0
  279. package/src/core/i18n/messages_defaultSet/da.ts +356 -0
  280. package/src/core/i18n/messages_defaultSet/de.ts +543 -0
  281. package/src/core/i18n/messages_defaultSet/el.ts +512 -0
  282. package/src/core/i18n/messages_defaultSet/en.ts +528 -0
  283. package/src/core/i18n/messages_defaultSet/es.ts +525 -0
  284. package/src/core/i18n/messages_defaultSet/fa.ts +480 -0
  285. package/src/core/i18n/messages_defaultSet/fi.ts +426 -0
  286. package/src/core/i18n/messages_defaultSet/fr.ts +458 -0
  287. package/src/core/i18n/messages_defaultSet/hu.ts +512 -0
  288. package/src/core/i18n/messages_defaultSet/index.ts +73 -0
  289. package/src/core/i18n/messages_defaultSet/it.ts +366 -0
  290. package/src/core/i18n/messages_defaultSet/ja.ts +369 -0
  291. package/src/core/i18n/messages_defaultSet/ka.ts +537 -0
  292. package/src/core/i18n/messages_defaultSet/lt.ts +233 -0
  293. package/src/core/i18n/messages_defaultSet/lv.ts +229 -0
  294. package/src/core/i18n/messages_defaultSet/nl.ts +324 -0
  295. package/src/core/i18n/messages_defaultSet/no.ts +228 -0
  296. package/src/core/i18n/messages_defaultSet/pl.ts +328 -0
  297. package/src/core/i18n/messages_defaultSet/pt-BR.ts +398 -0
  298. package/src/core/i18n/messages_defaultSet/pt.ts +519 -0
  299. package/src/core/i18n/messages_defaultSet/ru.ts +259 -0
  300. package/src/core/i18n/messages_defaultSet/sk.ts +503 -0
  301. package/src/core/i18n/messages_defaultSet/sv.ts +229 -0
  302. package/src/core/i18n/messages_defaultSet/th.ts +491 -0
  303. package/src/core/i18n/messages_defaultSet/tr.ts +306 -0
  304. package/src/core/i18n/messages_defaultSet/types.ts +36 -0
  305. package/src/core/i18n/messages_defaultSet/uk.ts +517 -0
  306. package/src/core/i18n/messages_defaultSet/zh-CN.ts +462 -0
  307. package/src/core/i18n/messages_defaultSet/zh-TW.ts +471 -0
  308. package/src/core/kcClsx.ts +258 -0
  309. package/src/core/kcSanitize/HtmlPolicyBuilder.ts +242 -0
  310. package/src/core/kcSanitize/KcSanitizer.ts +60 -0
  311. package/src/core/kcSanitize/KcSanitizerPolicy.ts +274 -0
  312. package/src/core/kcSanitize/index.ts +5 -0
  313. package/src/core/userProfileApi/index.ts +1 -0
  314. package/src/core/userProfileApi/kcNumberUnFormat.ts +109 -0
  315. package/src/core/userProfileApi/userProfileApi.ts +1564 -0
  316. package/src/i18n/GenericI18n.tsx +82 -0
  317. package/src/i18n/i18nBuilder.ts +101 -0
  318. package/src/i18n/index.ts +3 -0
  319. package/src/i18n/useI18n.tsx +179 -0
  320. package/src/import.meta.env.BASE_URL.ts +52 -0
  321. package/src/kcSanitize.ts +1 -0
  322. package/src/tools/Array.prototype.every.ts +68 -0
  323. package/src/tools/DeepPartial.ts +3 -0
  324. package/src/tools/JSX.ts +5 -0
  325. package/src/tools/Object.fromEntries.ts +21 -0
  326. package/src/tools/ValueOf.ts +2 -0
  327. package/src/tools/clsx.ts +8 -0
  328. package/src/tools/clsx_withTransform.ts +55 -0
  329. package/src/tools/deepAssign.ts +74 -0
  330. package/src/tools/emailRegExp.ts +2 -0
  331. package/src/tools/extractLastParenthesisContent.ts +43 -0
  332. package/src/tools/structuredCloneButFunctions.ts +24 -0
  333. package/src/tools/useConst.ts +10 -0
  334. package/src/tools/useExclusiveAppInstanceEffect.ts +50 -0
  335. package/src/tools/useInsertLinkTags.ts +55 -0
  336. package/src/tools/useInsertScriptTags.ts +89 -0
  337. package/src/tools/useIsPasswordRevealed.ts +45 -0
  338. package/src/tools/useOnFirstMount.ts +26 -0
  339. package/src/tools/useSetClassname.ts +24 -0
  340. package/src/tools/vendor/dompurify.ts +3 -0
  341. package/src/tools/waitForElementMountedOnDom.ts +28 -0
  342. package/src/useKcClsx.tsx +33 -0
  343. package/src/useUserProfileForm.tsx +171 -0
  344. package/tools/Array.prototype.every.d.ts +0 -0
  345. package/tools/Array.prototype.every.js +59 -0
  346. package/tools/DeepPartial.d.ts +3 -0
  347. package/tools/DeepPartial.js +1 -0
  348. package/tools/JSX.d.ts +5 -0
  349. package/tools/JSX.js +1 -0
  350. package/tools/Object.fromEntries.d.ts +1 -0
  351. package/tools/Object.fromEntries.js +16 -0
  352. package/tools/ValueOf.d.ts +2 -0
  353. package/tools/ValueOf.js +1 -0
  354. package/tools/clsx.d.ts +3 -0
  355. package/tools/clsx.js +5 -0
  356. package/tools/clsx_withTransform.d.ts +5 -0
  357. package/tools/clsx_withTransform.js +42 -0
  358. package/tools/deepAssign.d.ts +5 -0
  359. package/tools/deepAssign.js +56 -0
  360. package/tools/emailRegExp.d.ts +1 -0
  361. package/tools/emailRegExp.js +1 -0
  362. package/tools/extractLastParenthesisContent.d.ts +6 -0
  363. package/tools/extractLastParenthesisContent.js +35 -0
  364. package/tools/structuredCloneButFunctions.d.ts +7 -0
  365. package/tools/structuredCloneButFunctions.js +18 -0
  366. package/tools/useConst.d.ts +5 -0
  367. package/tools/useConst.js +9 -0
  368. package/tools/useExclusiveAppInstanceEffect.d.ts +14 -0
  369. package/tools/useExclusiveAppInstanceEffect.js +29 -0
  370. package/tools/useInsertLinkTags.d.ts +12 -0
  371. package/tools/useInsertLinkTags.js +37 -0
  372. package/tools/useInsertScriptTags.d.ts +19 -0
  373. package/tools/useInsertScriptTags.js +60 -0
  374. package/tools/useIsPasswordRevealed.d.ts +10 -0
  375. package/tools/useIsPasswordRevealed.js +32 -0
  376. package/tools/useOnFirstMount.d.ts +5 -0
  377. package/tools/useOnFirstMount.js +19 -0
  378. package/tools/useSetClassname.d.ts +4 -0
  379. package/tools/useSetClassname.js +15 -0
  380. package/tools/vendor/dompurify.d.ts +2 -0
  381. package/tools/vendor/dompurify.js +2 -0
  382. package/tools/waitForElementMountedOnDom.d.ts +3 -0
  383. package/tools/waitForElementMountedOnDom.js +20 -0
  384. package/useKcClsx.d.ts +12 -0
  385. package/useKcClsx.js +20 -0
  386. package/useUserProfileForm.d.ts +65 -0
  387. package/useUserProfileForm.js +55 -0
@@ -0,0 +1,1119 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ /* eslint-disable @typescript-eslint/no-explicit-any */
13
+ import "../../tools/Array.prototype.every";
14
+ import { assert } from "tsafe/assert";
15
+ import { emailRegexp } from "../../tools/emailRegExp";
16
+ import { formatNumber, unFormatNumberOnSubmit } from "./kcNumberUnFormat";
17
+ import { structuredCloneButFunctions } from "../../tools/structuredCloneButFunctions";
18
+ import { id } from "tsafe/id";
19
+ assert();
20
+ const cachedUserProfileApiByKcContext = new WeakMap();
21
+ export function getUserProfileApi(params) {
22
+ const { kcContext, doMakeUserConfirmPassword } = params;
23
+ use_cache: {
24
+ const userProfileApi_cache = cachedUserProfileApiByKcContext.get(kcContext);
25
+ if (userProfileApi_cache === undefined) {
26
+ break use_cache;
27
+ }
28
+ return userProfileApi_cache;
29
+ }
30
+ const userProfileApi = getUserProfileApi_noCache({ kcContext, doMakeUserConfirmPassword });
31
+ cachedUserProfileApiByKcContext.set(kcContext, userProfileApi);
32
+ return userProfileApi;
33
+ }
34
+ function getUserProfileApi_noCache(params) {
35
+ const { kcContext, doMakeUserConfirmPassword } = params;
36
+ unFormatNumberOnSubmit();
37
+ let state = getInitialState({ kcContext, doMakeUserConfirmPassword });
38
+ const callbacks = new Set();
39
+ return {
40
+ dispatchFormAction: action => {
41
+ state = reducer({ action, kcContext, doMakeUserConfirmPassword, state });
42
+ callbacks.forEach(callback => callback());
43
+ },
44
+ getFormState: () => formStateSelector({ state }),
45
+ subscribeToFormState: callback => {
46
+ callbacks.add(callback);
47
+ return {
48
+ unsubscribe: () => {
49
+ callbacks.delete(callback);
50
+ }
51
+ };
52
+ }
53
+ };
54
+ }
55
+ function getInitialState(params) {
56
+ var _a, _b;
57
+ const { kcContext } = params;
58
+ const { getErrors } = createGetErrors({ kcContext });
59
+ // NOTE: We don't use te kcContext.profile.attributes directly because
60
+ // they don't includes the password and password confirm fields and we want to add them.
61
+ // We also want to apply some retro-compatibility and consistency patches.
62
+ const attributes = (() => {
63
+ var _a;
64
+ mock_user_profile_attributes_for_older_keycloak_versions: {
65
+ if ("profile" in kcContext &&
66
+ "attributesByName" in kcContext.profile &&
67
+ Object.keys(kcContext.profile.attributesByName).length !== 0) {
68
+ break mock_user_profile_attributes_for_older_keycloak_versions;
69
+ }
70
+ if ("register" in kcContext &&
71
+ kcContext.register instanceof Object &&
72
+ "formData" in kcContext.register) {
73
+ //NOTE: Handle legacy register.ftl page
74
+ return ["firstName", "lastName", "email", "username"]
75
+ .filter(name => name !== "username" ? true : !kcContext.realm.registrationEmailAsUsername)
76
+ .map(name => {
77
+ var _a;
78
+ return id({
79
+ name: name,
80
+ displayName: id(`\${${name}}`),
81
+ required: true,
82
+ value: (_a = kcContext.register.formData[name]) !== null && _a !== void 0 ? _a : "",
83
+ html5DataAnnotations: {},
84
+ readOnly: false,
85
+ validators: {},
86
+ annotations: {},
87
+ autocomplete: (() => {
88
+ switch (name) {
89
+ case "email":
90
+ return "email";
91
+ case "username":
92
+ return "username";
93
+ default:
94
+ return undefined;
95
+ }
96
+ })()
97
+ });
98
+ });
99
+ }
100
+ if ("user" in kcContext && kcContext.user instanceof Object) {
101
+ //NOTE: Handle legacy login-update-profile.ftl
102
+ return ["username", "email", "firstName", "lastName"]
103
+ .filter(name => name !== "username" ? true : kcContext.user.editUsernameAllowed)
104
+ .map(name => {
105
+ var _a;
106
+ return id({
107
+ name: name,
108
+ displayName: id(`\${${name}}`),
109
+ required: true,
110
+ value: (_a = kcContext.user[name]) !== null && _a !== void 0 ? _a : "",
111
+ html5DataAnnotations: {},
112
+ readOnly: false,
113
+ validators: {},
114
+ annotations: {},
115
+ autocomplete: (() => {
116
+ switch (name) {
117
+ case "email":
118
+ return "email";
119
+ case "username":
120
+ return "username";
121
+ default:
122
+ return undefined;
123
+ }
124
+ })()
125
+ });
126
+ });
127
+ }
128
+ if ("email" in kcContext && kcContext.email instanceof Object) {
129
+ //NOTE: Handle legacy update-email.ftl
130
+ return [
131
+ id({
132
+ name: "email",
133
+ displayName: id(`\${email}`),
134
+ required: true,
135
+ value: (_a = kcContext.email.value) !== null && _a !== void 0 ? _a : "",
136
+ html5DataAnnotations: {},
137
+ readOnly: false,
138
+ validators: {},
139
+ annotations: {},
140
+ autocomplete: "email"
141
+ })
142
+ ];
143
+ }
144
+ assert(false, "Unable to mock user profile from the current kcContext");
145
+ }
146
+ return Object.values(kcContext.profile.attributesByName).map(structuredCloneButFunctions);
147
+ })();
148
+ /* See: https://github.com/keycloak/keycloak/issues/38029 and https://github.com/keycloakify/keycloakify/issues/837 */
149
+ add_locale_attribute_for_keycloak_prior_to_26_2_0: {
150
+ if (kcContext.locale === undefined) {
151
+ break add_locale_attribute_for_keycloak_prior_to_26_2_0;
152
+ }
153
+ if (attributes.find(attribute => attribute.name === "locale") !== undefined) {
154
+ break add_locale_attribute_for_keycloak_prior_to_26_2_0;
155
+ }
156
+ attributes.push(id({
157
+ validators: {},
158
+ displayName: "locale",
159
+ values: [],
160
+ annotations: {},
161
+ required: false,
162
+ html5DataAnnotations: {},
163
+ multivalued: false,
164
+ readOnly: false,
165
+ name: "locale"
166
+ }));
167
+ }
168
+ attributes.forEach(attribute => {
169
+ var _a, _b, _c;
170
+ if (attribute.name === "password-confirm") {
171
+ attribute.annotations.inputType = "hidden";
172
+ }
173
+ if (attribute.name === "locale") {
174
+ assert(kcContext.locale !== undefined);
175
+ attribute.annotations.inputType = "hidden";
176
+ attribute.value = kcContext.locale.currentLanguageTag;
177
+ delete attribute.values;
178
+ }
179
+ patch_legacy_group: {
180
+ if (typeof attribute.group !== "string") {
181
+ break patch_legacy_group;
182
+ }
183
+ const { group, groupDisplayHeader, groupDisplayDescription, groupAnnotations } = attribute;
184
+ delete attribute.group;
185
+ // @ts-expect-error: We know what we are doing
186
+ delete attribute.groupDisplayHeader;
187
+ // @ts-expect-error: We know what we are doing
188
+ delete attribute.groupDisplayDescription;
189
+ // @ts-expect-error: We know what we are doing
190
+ delete attribute.groupAnnotations;
191
+ if (group === "") {
192
+ break patch_legacy_group;
193
+ }
194
+ attribute.group = {
195
+ name: group,
196
+ displayHeader: groupDisplayHeader,
197
+ displayDescription: groupDisplayDescription,
198
+ annotations: groupAnnotations,
199
+ html5DataAnnotations: {}
200
+ };
201
+ }
202
+ // Attributes with options rendered by default as select inputs
203
+ if (attribute.validators.options !== undefined &&
204
+ attribute.annotations.inputType === undefined) {
205
+ attribute.annotations.inputType = "select";
206
+ }
207
+ // Consistency patch on values/value property
208
+ {
209
+ if (getIsMultivaluedSingleField({ attribute })) {
210
+ attribute.multivalued = true;
211
+ }
212
+ if (attribute.multivalued) {
213
+ (_a = attribute.values) !== null && _a !== void 0 ? _a : (attribute.values = attribute.value !== undefined ? [attribute.value] : []);
214
+ delete attribute.value;
215
+ }
216
+ else {
217
+ (_b = attribute.value) !== null && _b !== void 0 ? _b : (attribute.value = (_c = attribute.values) === null || _c === void 0 ? void 0 : _c[0]);
218
+ delete attribute.values;
219
+ }
220
+ }
221
+ });
222
+ add_password_and_password_confirm: {
223
+ if (!kcContext.passwordRequired) {
224
+ break add_password_and_password_confirm;
225
+ }
226
+ attributes.forEach((attribute, i) => {
227
+ if (attribute.name !== (kcContext.realm.registrationEmailAsUsername ? "email" : "username")) {
228
+ // NOTE: We want to add password and password-confirm after the field that identifies the user.
229
+ // It's either email or username.
230
+ return;
231
+ }
232
+ attributes.splice(i + 1, 0, {
233
+ name: "password",
234
+ displayName: id("${password}"),
235
+ required: true,
236
+ readOnly: false,
237
+ validators: {},
238
+ annotations: {},
239
+ autocomplete: "new-password",
240
+ html5DataAnnotations: {}
241
+ }, {
242
+ name: "password-confirm",
243
+ displayName: id("${passwordConfirm}"),
244
+ required: true,
245
+ readOnly: false,
246
+ validators: {},
247
+ annotations: {},
248
+ html5DataAnnotations: {},
249
+ autocomplete: "new-password"
250
+ });
251
+ });
252
+ }
253
+ const initialFormFieldState = [];
254
+ for (const attribute of attributes) {
255
+ handle_multi_valued_attribute: {
256
+ if (!attribute.multivalued) {
257
+ break handle_multi_valued_attribute;
258
+ }
259
+ const values = ((_a = attribute.values) === null || _a === void 0 ? void 0 : _a.length) ? attribute.values : [""];
260
+ apply_validator_min_range: {
261
+ if (getIsMultivaluedSingleField({ attribute })) {
262
+ break apply_validator_min_range;
263
+ }
264
+ const validator = attribute.validators.multivalued;
265
+ if (validator === undefined) {
266
+ break apply_validator_min_range;
267
+ }
268
+ const { min: minStr } = validator;
269
+ if (!minStr) {
270
+ break apply_validator_min_range;
271
+ }
272
+ const min = parseInt(`${minStr}`);
273
+ for (let index = values.length; index < min; index++) {
274
+ values.push("");
275
+ }
276
+ }
277
+ initialFormFieldState.push({
278
+ attribute,
279
+ valueOrValues: values
280
+ });
281
+ continue;
282
+ }
283
+ initialFormFieldState.push({
284
+ attribute,
285
+ valueOrValues: (_b = attribute.value) !== null && _b !== void 0 ? _b : ""
286
+ });
287
+ }
288
+ const initialState = {
289
+ formFieldStates: initialFormFieldState.map(({ attribute, valueOrValues }) => ({
290
+ attribute,
291
+ errors: getErrors({
292
+ attributeName: attribute.name,
293
+ formFieldStates: initialFormFieldState
294
+ }),
295
+ hasLostFocusAtLeastOnce: valueOrValues instanceof Array && !getIsMultivaluedSingleField({ attribute })
296
+ ? valueOrValues.map(() => false)
297
+ : false,
298
+ valueOrValues: valueOrValues
299
+ }))
300
+ };
301
+ return initialState;
302
+ }
303
+ const formStateByState = new WeakMap();
304
+ function formStateSelector(params) {
305
+ const { state } = params;
306
+ use_memoized_value: {
307
+ const formState = formStateByState.get(state);
308
+ if (formState === undefined) {
309
+ break use_memoized_value;
310
+ }
311
+ return formState;
312
+ }
313
+ return {
314
+ formFieldStates: state.formFieldStates.map((_a) => {
315
+ var { errors, hasLostFocusAtLeastOnce: hasLostFocusAtLeastOnceOrArr, attribute } = _a, valueOrValuesWrap = __rest(_a, ["errors", "hasLostFocusAtLeastOnce", "attribute"]);
316
+ return (Object.assign({ displayableErrors: errors.filter(error => {
317
+ const hasLostFocusAtLeastOnce = typeof hasLostFocusAtLeastOnceOrArr === "boolean"
318
+ ? hasLostFocusAtLeastOnceOrArr
319
+ : error.fieldIndex !== undefined
320
+ ? hasLostFocusAtLeastOnceOrArr[error.fieldIndex]
321
+ : hasLostFocusAtLeastOnceOrArr[hasLostFocusAtLeastOnceOrArr.length - 1];
322
+ switch (error.source.type) {
323
+ case "server":
324
+ return true;
325
+ case "other":
326
+ switch (error.source.rule) {
327
+ case "requiredField":
328
+ return hasLostFocusAtLeastOnce;
329
+ case "passwordConfirmMatchesPassword":
330
+ return hasLostFocusAtLeastOnce;
331
+ }
332
+ assert(false);
333
+ break;
334
+ case "passwordPolicy":
335
+ switch (error.source.name) {
336
+ case "length":
337
+ return hasLostFocusAtLeastOnce;
338
+ case "maxLength":
339
+ return hasLostFocusAtLeastOnce;
340
+ case "digits":
341
+ return hasLostFocusAtLeastOnce;
342
+ case "lowerCase":
343
+ return hasLostFocusAtLeastOnce;
344
+ case "upperCase":
345
+ return hasLostFocusAtLeastOnce;
346
+ case "specialChars":
347
+ return hasLostFocusAtLeastOnce;
348
+ case "notUsername":
349
+ return true;
350
+ case "notEmail":
351
+ return true;
352
+ }
353
+ assert(false);
354
+ break;
355
+ case "validator":
356
+ switch (error.source.name) {
357
+ case "length":
358
+ return hasLostFocusAtLeastOnce;
359
+ case "pattern":
360
+ return hasLostFocusAtLeastOnce;
361
+ case "email":
362
+ return hasLostFocusAtLeastOnce;
363
+ case "integer":
364
+ return hasLostFocusAtLeastOnce;
365
+ case "multivalued":
366
+ return hasLostFocusAtLeastOnce;
367
+ case "options":
368
+ return hasLostFocusAtLeastOnce;
369
+ }
370
+ assert(false);
371
+ }
372
+ }), attribute }, valueOrValuesWrap));
373
+ }),
374
+ isFormSubmittable: state.formFieldStates.every(({ errors }) => errors.length === 0)
375
+ };
376
+ }
377
+ function reducer(params) {
378
+ const { kcContext, doMakeUserConfirmPassword, action } = params;
379
+ let { state } = params;
380
+ const { getErrors } = createGetErrors({ kcContext });
381
+ const formFieldState = state.formFieldStates.find(({ attribute }) => attribute.name === action.name);
382
+ assert(formFieldState !== undefined);
383
+ (() => {
384
+ var _a;
385
+ switch (action.action) {
386
+ case "update":
387
+ formFieldState.valueOrValues = action.valueOrValues;
388
+ apply_formatters: {
389
+ const { attribute } = formFieldState;
390
+ const { kcNumberFormat } = (_a = attribute.html5DataAnnotations) !== null && _a !== void 0 ? _a : {};
391
+ if (!kcNumberFormat) {
392
+ break apply_formatters;
393
+ }
394
+ if (formFieldState.valueOrValues instanceof Array) {
395
+ formFieldState.valueOrValues = formFieldState.valueOrValues.map(value => formatNumber(value, kcNumberFormat));
396
+ }
397
+ else {
398
+ formFieldState.valueOrValues = formatNumber(formFieldState.valueOrValues, kcNumberFormat);
399
+ }
400
+ }
401
+ formFieldState.errors = getErrors({
402
+ attributeName: action.name,
403
+ formFieldStates: state.formFieldStates
404
+ });
405
+ simulate_focus_lost: {
406
+ const { displayErrorsImmediately = false } = action;
407
+ if (!displayErrorsImmediately) {
408
+ break simulate_focus_lost;
409
+ }
410
+ for (const fieldIndex of action.valueOrValues instanceof Array
411
+ ? action.valueOrValues.map((...[, index]) => index)
412
+ : [undefined]) {
413
+ state = reducer({
414
+ state,
415
+ kcContext,
416
+ doMakeUserConfirmPassword,
417
+ action: {
418
+ action: "focus lost",
419
+ name: action.name,
420
+ fieldIndex
421
+ }
422
+ });
423
+ }
424
+ }
425
+ update_password_confirm: {
426
+ if (doMakeUserConfirmPassword) {
427
+ break update_password_confirm;
428
+ }
429
+ if (action.name !== "password") {
430
+ break update_password_confirm;
431
+ }
432
+ state = reducer({
433
+ state,
434
+ kcContext,
435
+ doMakeUserConfirmPassword,
436
+ action: {
437
+ action: "update",
438
+ name: "password-confirm",
439
+ valueOrValues: action.valueOrValues,
440
+ displayErrorsImmediately: action.displayErrorsImmediately
441
+ }
442
+ });
443
+ }
444
+ trigger_password_confirm_validation_on_password_change: {
445
+ if (!doMakeUserConfirmPassword) {
446
+ break trigger_password_confirm_validation_on_password_change;
447
+ }
448
+ if (action.name !== "password") {
449
+ break trigger_password_confirm_validation_on_password_change;
450
+ }
451
+ state = reducer({
452
+ state,
453
+ kcContext,
454
+ doMakeUserConfirmPassword,
455
+ action: {
456
+ action: "update",
457
+ name: "password-confirm",
458
+ valueOrValues: (() => {
459
+ const formFieldState = state.formFieldStates.find(({ attribute }) => attribute.name === "password-confirm");
460
+ assert(formFieldState !== undefined);
461
+ return formFieldState.valueOrValues;
462
+ })(),
463
+ displayErrorsImmediately: action.displayErrorsImmediately
464
+ }
465
+ });
466
+ }
467
+ return;
468
+ case "focus lost":
469
+ if (formFieldState.hasLostFocusAtLeastOnce instanceof Array) {
470
+ const { fieldIndex } = action;
471
+ assert(fieldIndex !== undefined);
472
+ formFieldState.hasLostFocusAtLeastOnce[fieldIndex] = true;
473
+ return;
474
+ }
475
+ formFieldState.hasLostFocusAtLeastOnce = true;
476
+ return;
477
+ }
478
+ assert(false);
479
+ })();
480
+ return Object.assign({}, state);
481
+ }
482
+ function createGetErrors(params) {
483
+ const { kcContext } = params;
484
+ const { messagesPerField, passwordPolicies } = kcContext;
485
+ function getErrors(params) {
486
+ var _a, _b;
487
+ const { attributeName, formFieldStates } = params;
488
+ const formFieldState = formFieldStates.find(({ attribute }) => attribute.name === attributeName);
489
+ assert(formFieldState !== undefined);
490
+ const { attribute } = formFieldState;
491
+ const valueOrValues = (() => {
492
+ var _a;
493
+ let { valueOrValues } = formFieldState;
494
+ unFormat_number: {
495
+ const { kcNumberUnFormat } = (_a = attribute.html5DataAnnotations) !== null && _a !== void 0 ? _a : {};
496
+ if (!kcNumberUnFormat) {
497
+ break unFormat_number;
498
+ }
499
+ if (valueOrValues instanceof Array) {
500
+ valueOrValues = valueOrValues.map(value => formatNumber(value, kcNumberUnFormat));
501
+ }
502
+ else {
503
+ valueOrValues = formatNumber(valueOrValues, kcNumberUnFormat);
504
+ }
505
+ }
506
+ return valueOrValues;
507
+ })();
508
+ assert(attribute !== undefined);
509
+ server_side_error: {
510
+ if (attribute.multivalued) {
511
+ const defaultValues = ((_a = attribute.values) === null || _a === void 0 ? void 0 : _a.length) ? attribute.values : [""];
512
+ assert(valueOrValues instanceof Array);
513
+ const values = valueOrValues;
514
+ if (JSON.stringify(defaultValues) !==
515
+ JSON.stringify(values.slice(0, defaultValues.length))) {
516
+ break server_side_error;
517
+ }
518
+ }
519
+ else {
520
+ const defaultValue = (_b = attribute.value) !== null && _b !== void 0 ? _b : "";
521
+ assert(typeof valueOrValues === "string");
522
+ const value = valueOrValues;
523
+ if (defaultValue !== value) {
524
+ break server_side_error;
525
+ }
526
+ }
527
+ let doesErrorExist;
528
+ try {
529
+ doesErrorExist = messagesPerField.existsError(attributeName);
530
+ }
531
+ catch (_c) {
532
+ break server_side_error;
533
+ }
534
+ if (!doesErrorExist) {
535
+ break server_side_error;
536
+ }
537
+ const errorMessageStr = messagesPerField.get(attributeName);
538
+ return [
539
+ {
540
+ advancedMsgArgs: [errorMessageStr],
541
+ fieldIndex: undefined,
542
+ source: {
543
+ type: "server"
544
+ }
545
+ }
546
+ ];
547
+ }
548
+ handle_multi_valued_multi_fields: {
549
+ if (!attribute.multivalued) {
550
+ break handle_multi_valued_multi_fields;
551
+ }
552
+ if (getIsMultivaluedSingleField({ attribute })) {
553
+ break handle_multi_valued_multi_fields;
554
+ }
555
+ assert(valueOrValues instanceof Array);
556
+ const values = valueOrValues;
557
+ const errors = values
558
+ .map((...[, index]) => {
559
+ const specificValueErrors = getErrors({
560
+ attributeName,
561
+ formFieldStates: formFieldStates.map(formFieldState => {
562
+ if (formFieldState.attribute.name === attributeName) {
563
+ assert(formFieldState.valueOrValues instanceof Array);
564
+ return {
565
+ attribute: Object.assign(Object.assign({}, attribute), { annotations: Object.assign(Object.assign({}, attribute.annotations), { inputType: undefined }), multivalued: false }),
566
+ valueOrValues: formFieldState.valueOrValues[index]
567
+ };
568
+ }
569
+ return formFieldState;
570
+ })
571
+ });
572
+ return specificValueErrors
573
+ .filter(error => {
574
+ if (error.source.type === "other" && error.source.rule === "requiredField") {
575
+ return false;
576
+ }
577
+ return true;
578
+ })
579
+ .map((error) => (Object.assign(Object.assign({}, error), { fieldIndex: index })));
580
+ })
581
+ .reduce((acc, errors) => [...acc, ...errors], []);
582
+ required_field: {
583
+ if (!attribute.required) {
584
+ break required_field;
585
+ }
586
+ if (values.every(value => value !== "")) {
587
+ break required_field;
588
+ }
589
+ errors.push({
590
+ advancedMsgArgs: [
591
+ "error-user-attribute-required"
592
+ ],
593
+ fieldIndex: undefined,
594
+ source: {
595
+ type: "other",
596
+ rule: "requiredField"
597
+ }
598
+ });
599
+ }
600
+ return errors;
601
+ }
602
+ handle_multi_valued_single_field: {
603
+ if (!attribute.multivalued) {
604
+ break handle_multi_valued_single_field;
605
+ }
606
+ if (!getIsMultivaluedSingleField({ attribute })) {
607
+ break handle_multi_valued_single_field;
608
+ }
609
+ const validatorName = "multivalued";
610
+ const validator = attribute.validators[validatorName];
611
+ if (validator === undefined) {
612
+ return [];
613
+ }
614
+ const { min: minStr } = validator;
615
+ const min = minStr ? parseInt(`${minStr}`) : attribute.required ? 1 : 0;
616
+ assert(!isNaN(min));
617
+ const { max: maxStr } = validator;
618
+ const max = !maxStr ? Infinity : parseInt(`${maxStr}`);
619
+ assert(!isNaN(max));
620
+ assert(valueOrValues instanceof Array);
621
+ const values = valueOrValues;
622
+ if (min <= values.length && values.length <= max) {
623
+ return [];
624
+ }
625
+ return [
626
+ {
627
+ advancedMsgArgs: [
628
+ "error-invalid-multivalued-size",
629
+ `${min}`,
630
+ `${max}`
631
+ ],
632
+ fieldIndex: undefined,
633
+ source: {
634
+ type: "validator",
635
+ name: validatorName
636
+ }
637
+ }
638
+ ];
639
+ }
640
+ assert(typeof valueOrValues === "string");
641
+ const value = valueOrValues;
642
+ const errors = [];
643
+ check_password_policies: {
644
+ if (attributeName !== "password") {
645
+ break check_password_policies;
646
+ }
647
+ if (passwordPolicies === undefined) {
648
+ break check_password_policies;
649
+ }
650
+ check_password_policy_x: {
651
+ const policyName = "length";
652
+ const policy = passwordPolicies[policyName];
653
+ if (!policy) {
654
+ break check_password_policy_x;
655
+ }
656
+ const minLength = policy;
657
+ if (value.length >= minLength) {
658
+ break check_password_policy_x;
659
+ }
660
+ errors.push({
661
+ advancedMsgArgs: [
662
+ "invalidPasswordMinLengthMessage",
663
+ `${minLength}`
664
+ ],
665
+ fieldIndex: undefined,
666
+ source: {
667
+ type: "passwordPolicy",
668
+ name: policyName
669
+ }
670
+ });
671
+ }
672
+ check_password_policy_x: {
673
+ const policyName = "maxLength";
674
+ const policy = passwordPolicies[policyName];
675
+ if (!policy) {
676
+ break check_password_policy_x;
677
+ }
678
+ const maxLength = policy;
679
+ if (value.length <= maxLength) {
680
+ break check_password_policy_x;
681
+ }
682
+ errors.push({
683
+ advancedMsgArgs: [
684
+ "invalidPasswordMaxLengthMessage",
685
+ `${maxLength}`
686
+ ],
687
+ fieldIndex: undefined,
688
+ source: {
689
+ type: "passwordPolicy",
690
+ name: policyName
691
+ }
692
+ });
693
+ }
694
+ check_password_policy_x: {
695
+ const policyName = "digits";
696
+ const policy = passwordPolicies[policyName];
697
+ if (!policy) {
698
+ break check_password_policy_x;
699
+ }
700
+ const minNumberOfDigits = policy;
701
+ if (value.split("").filter(char => !isNaN(parseInt(char))).length >= minNumberOfDigits) {
702
+ break check_password_policy_x;
703
+ }
704
+ errors.push({
705
+ advancedMsgArgs: [
706
+ "invalidPasswordMinDigitsMessage",
707
+ `${minNumberOfDigits}`
708
+ ],
709
+ fieldIndex: undefined,
710
+ source: {
711
+ type: "passwordPolicy",
712
+ name: policyName
713
+ }
714
+ });
715
+ }
716
+ check_password_policy_x: {
717
+ const policyName = "lowerCase";
718
+ const policy = passwordPolicies[policyName];
719
+ if (!policy) {
720
+ break check_password_policy_x;
721
+ }
722
+ const minNumberOfLowerCaseChar = policy;
723
+ if (value
724
+ .split("")
725
+ .filter(char => char === char.toLowerCase() && char !== char.toUpperCase())
726
+ .length >= minNumberOfLowerCaseChar) {
727
+ break check_password_policy_x;
728
+ }
729
+ errors.push({
730
+ advancedMsgArgs: [
731
+ "invalidPasswordMinLowerCaseCharsMessage",
732
+ `${minNumberOfLowerCaseChar}`
733
+ ],
734
+ fieldIndex: undefined,
735
+ source: {
736
+ type: "passwordPolicy",
737
+ name: policyName
738
+ }
739
+ });
740
+ }
741
+ check_password_policy_x: {
742
+ const policyName = "upperCase";
743
+ const policy = passwordPolicies[policyName];
744
+ if (!policy) {
745
+ break check_password_policy_x;
746
+ }
747
+ const minNumberOfUpperCaseChar = policy;
748
+ if (value
749
+ .split("")
750
+ .filter(char => char === char.toUpperCase() && char !== char.toLowerCase())
751
+ .length >= minNumberOfUpperCaseChar) {
752
+ break check_password_policy_x;
753
+ }
754
+ errors.push({
755
+ advancedMsgArgs: [
756
+ "invalidPasswordMinUpperCaseCharsMessage",
757
+ `${minNumberOfUpperCaseChar}`
758
+ ],
759
+ fieldIndex: undefined,
760
+ source: {
761
+ type: "passwordPolicy",
762
+ name: policyName
763
+ }
764
+ });
765
+ }
766
+ check_password_policy_x: {
767
+ const policyName = "specialChars";
768
+ const policy = passwordPolicies[policyName];
769
+ if (!policy) {
770
+ break check_password_policy_x;
771
+ }
772
+ const minNumberOfSpecialChar = policy;
773
+ if (value.split("").filter(char => !char.match(/[a-zA-Z0-9]/)).length >=
774
+ minNumberOfSpecialChar) {
775
+ break check_password_policy_x;
776
+ }
777
+ errors.push({
778
+ advancedMsgArgs: [
779
+ "invalidPasswordMinSpecialCharsMessage",
780
+ `${minNumberOfSpecialChar}`
781
+ ],
782
+ fieldIndex: undefined,
783
+ source: {
784
+ type: "passwordPolicy",
785
+ name: policyName
786
+ }
787
+ });
788
+ }
789
+ check_password_policy_x: {
790
+ const policyName = "notUsername";
791
+ const notUsername = passwordPolicies[policyName];
792
+ if (!notUsername) {
793
+ break check_password_policy_x;
794
+ }
795
+ const usernameFormFieldState = formFieldStates.find(formFieldState => formFieldState.attribute.name === "username");
796
+ if (!usernameFormFieldState) {
797
+ break check_password_policy_x;
798
+ }
799
+ const usernameValue = (() => {
800
+ var _a;
801
+ let { valueOrValues } = usernameFormFieldState;
802
+ assert(typeof valueOrValues === "string");
803
+ unFormat_number: {
804
+ const { kcNumberUnFormat } = (_a = attribute.html5DataAnnotations) !== null && _a !== void 0 ? _a : {};
805
+ if (!kcNumberUnFormat) {
806
+ break unFormat_number;
807
+ }
808
+ valueOrValues = formatNumber(valueOrValues, kcNumberUnFormat);
809
+ }
810
+ return valueOrValues;
811
+ })();
812
+ if (usernameValue === "") {
813
+ break check_password_policy_x;
814
+ }
815
+ if (value !== usernameValue) {
816
+ break check_password_policy_x;
817
+ }
818
+ errors.push({
819
+ advancedMsgArgs: [
820
+ "invalidPasswordNotUsernameMessage"
821
+ ],
822
+ fieldIndex: undefined,
823
+ source: {
824
+ type: "passwordPolicy",
825
+ name: policyName
826
+ }
827
+ });
828
+ }
829
+ check_password_policy_x: {
830
+ const policyName = "notEmail";
831
+ const notEmail = passwordPolicies[policyName];
832
+ if (!notEmail) {
833
+ break check_password_policy_x;
834
+ }
835
+ const emailFormFieldState = formFieldStates.find(formFieldState => formFieldState.attribute.name === "email");
836
+ if (!emailFormFieldState) {
837
+ break check_password_policy_x;
838
+ }
839
+ assert(typeof emailFormFieldState.valueOrValues === "string");
840
+ {
841
+ const emailValue = emailFormFieldState.valueOrValues;
842
+ if (emailValue === "") {
843
+ break check_password_policy_x;
844
+ }
845
+ if (value !== emailValue) {
846
+ break check_password_policy_x;
847
+ }
848
+ }
849
+ errors.push({
850
+ advancedMsgArgs: [
851
+ "invalidPasswordNotEmailMessage"
852
+ ],
853
+ fieldIndex: undefined,
854
+ source: {
855
+ type: "passwordPolicy",
856
+ name: policyName
857
+ }
858
+ });
859
+ }
860
+ }
861
+ password_confirm_matches_password: {
862
+ if (attributeName !== "password-confirm") {
863
+ break password_confirm_matches_password;
864
+ }
865
+ const passwordFormFieldState = formFieldStates.find(formFieldState => formFieldState.attribute.name === "password");
866
+ assert(passwordFormFieldState !== undefined);
867
+ assert(typeof passwordFormFieldState.valueOrValues === "string");
868
+ {
869
+ const passwordValue = passwordFormFieldState.valueOrValues;
870
+ if (value === passwordValue) {
871
+ break password_confirm_matches_password;
872
+ }
873
+ }
874
+ errors.push({
875
+ advancedMsgArgs: [
876
+ "invalidPasswordConfirmMessage"
877
+ ],
878
+ fieldIndex: undefined,
879
+ source: {
880
+ type: "other",
881
+ rule: "passwordConfirmMatchesPassword"
882
+ }
883
+ });
884
+ }
885
+ const { validators } = attribute;
886
+ required_field: {
887
+ if (!attribute.required) {
888
+ break required_field;
889
+ }
890
+ if (value !== "") {
891
+ break required_field;
892
+ }
893
+ errors.push({
894
+ advancedMsgArgs: [
895
+ "error-user-attribute-required"
896
+ ],
897
+ fieldIndex: undefined,
898
+ source: {
899
+ type: "other",
900
+ rule: "requiredField"
901
+ }
902
+ });
903
+ }
904
+ validator_x: {
905
+ const validatorName = "length";
906
+ const validator = validators[validatorName];
907
+ if (!validator) {
908
+ break validator_x;
909
+ }
910
+ const { "ignore.empty.value": ignoreEmptyValue = false, max, min } = validator;
911
+ if (ignoreEmptyValue && value === "") {
912
+ break validator_x;
913
+ }
914
+ const source = {
915
+ type: "validator",
916
+ name: validatorName
917
+ };
918
+ if (max && value.length > parseInt(`${max}`)) {
919
+ errors.push({
920
+ advancedMsgArgs: [
921
+ "error-invalid-length-too-long",
922
+ `${max}`
923
+ ],
924
+ fieldIndex: undefined,
925
+ source
926
+ });
927
+ }
928
+ if (min && value.length < parseInt(`${min}`)) {
929
+ errors.push({
930
+ advancedMsgArgs: [
931
+ "error-invalid-length-too-short",
932
+ `${min}`
933
+ ],
934
+ fieldIndex: undefined,
935
+ source
936
+ });
937
+ }
938
+ }
939
+ validator_x: {
940
+ const validatorName = "pattern";
941
+ const validator = validators[validatorName];
942
+ if (validator === undefined) {
943
+ break validator_x;
944
+ }
945
+ const { "ignore.empty.value": ignoreEmptyValue = false, pattern, "error-message": errorMessageKey } = validator;
946
+ if (ignoreEmptyValue && value === "") {
947
+ break validator_x;
948
+ }
949
+ if (new RegExp(pattern).test(value)) {
950
+ break validator_x;
951
+ }
952
+ const msgArgs = [
953
+ errorMessageKey !== null && errorMessageKey !== void 0 ? errorMessageKey : "shouldMatchPattern",
954
+ pattern
955
+ ];
956
+ errors.push({
957
+ advancedMsgArgs: msgArgs,
958
+ fieldIndex: undefined,
959
+ source: {
960
+ type: "validator",
961
+ name: validatorName
962
+ }
963
+ });
964
+ }
965
+ validator_x: {
966
+ {
967
+ const lastError = errors[errors.length - 1];
968
+ if (lastError !== undefined &&
969
+ lastError.source.type === "validator" &&
970
+ lastError.source.name === "pattern") {
971
+ break validator_x;
972
+ }
973
+ }
974
+ const validatorName = "email";
975
+ const validator = validators[validatorName];
976
+ if (validator === undefined) {
977
+ break validator_x;
978
+ }
979
+ const { "ignore.empty.value": ignoreEmptyValue = false } = validator;
980
+ if (ignoreEmptyValue && value === "") {
981
+ break validator_x;
982
+ }
983
+ if (emailRegexp.test(value)) {
984
+ break validator_x;
985
+ }
986
+ errors.push({
987
+ advancedMsgArgs: ["invalidEmailMessage"],
988
+ fieldIndex: undefined,
989
+ source: {
990
+ type: "validator",
991
+ name: validatorName
992
+ }
993
+ });
994
+ }
995
+ validator_x: {
996
+ const validatorName = "integer";
997
+ const validator = validators[validatorName];
998
+ if (validator === undefined) {
999
+ break validator_x;
1000
+ }
1001
+ const { "ignore.empty.value": ignoreEmptyValue = false, max, min } = validator;
1002
+ if (ignoreEmptyValue && value === "") {
1003
+ break validator_x;
1004
+ }
1005
+ const intValue = parseInt(value);
1006
+ const source = {
1007
+ type: "validator",
1008
+ name: validatorName
1009
+ };
1010
+ if (isNaN(intValue)) {
1011
+ const msgArgs = ["mustBeAnInteger"];
1012
+ errors.push({
1013
+ advancedMsgArgs: msgArgs,
1014
+ fieldIndex: undefined,
1015
+ source
1016
+ });
1017
+ break validator_x;
1018
+ }
1019
+ if (max && intValue > parseInt(`${max}`)) {
1020
+ errors.push({
1021
+ advancedMsgArgs: [
1022
+ "error-number-out-of-range-too-big",
1023
+ `${max}`
1024
+ ],
1025
+ fieldIndex: undefined,
1026
+ source
1027
+ });
1028
+ break validator_x;
1029
+ }
1030
+ if (min && intValue < parseInt(`${min}`)) {
1031
+ errors.push({
1032
+ advancedMsgArgs: [
1033
+ "error-number-out-of-range-too-small",
1034
+ `${min}`
1035
+ ],
1036
+ fieldIndex: undefined,
1037
+ source
1038
+ });
1039
+ break validator_x;
1040
+ }
1041
+ }
1042
+ validator_x: {
1043
+ const validatorName = "options";
1044
+ const validator = validators[validatorName];
1045
+ if (validator === undefined) {
1046
+ break validator_x;
1047
+ }
1048
+ if (value === "") {
1049
+ break validator_x;
1050
+ }
1051
+ if (validator.options.indexOf(value) >= 0) {
1052
+ break validator_x;
1053
+ }
1054
+ errors.push({
1055
+ advancedMsgArgs: ["notAValidOption"],
1056
+ fieldIndex: undefined,
1057
+ source: {
1058
+ type: "validator",
1059
+ name: validatorName
1060
+ }
1061
+ });
1062
+ }
1063
+ //TODO: Implement missing validators. See Validators type definition.
1064
+ return errors;
1065
+ }
1066
+ return { getErrors };
1067
+ }
1068
+ function getIsMultivaluedSingleField(params) {
1069
+ var _a, _b;
1070
+ const { attribute } = params;
1071
+ return (_b = (_a = attribute.annotations.inputType) === null || _a === void 0 ? void 0 : _a.startsWith("multiselect")) !== null && _b !== void 0 ? _b : false;
1072
+ }
1073
+ export function getButtonToDisplayForMultivaluedAttributeField(params) {
1074
+ const { attribute, values, fieldIndex } = params;
1075
+ const hasRemove = (() => {
1076
+ if (values.length === 1) {
1077
+ return false;
1078
+ }
1079
+ const minCount = (() => {
1080
+ const { multivalued } = attribute.validators;
1081
+ if (multivalued === undefined) {
1082
+ return undefined;
1083
+ }
1084
+ const minStr = multivalued.min;
1085
+ if (minStr === undefined) {
1086
+ return undefined;
1087
+ }
1088
+ return parseInt(`${minStr}`);
1089
+ })();
1090
+ if (minCount === undefined) {
1091
+ return true;
1092
+ }
1093
+ if (values.length === minCount) {
1094
+ return false;
1095
+ }
1096
+ return true;
1097
+ })();
1098
+ const hasAdd = (() => {
1099
+ if (fieldIndex + 1 !== values.length) {
1100
+ return false;
1101
+ }
1102
+ const maxCount = (() => {
1103
+ const { multivalued } = attribute.validators;
1104
+ if (multivalued === undefined) {
1105
+ return undefined;
1106
+ }
1107
+ const maxStr = multivalued.max;
1108
+ if (maxStr === undefined) {
1109
+ return undefined;
1110
+ }
1111
+ return parseInt(`${maxStr}`);
1112
+ })();
1113
+ if (maxCount === undefined) {
1114
+ return true;
1115
+ }
1116
+ return values.length !== maxCount;
1117
+ })();
1118
+ return { hasRemove, hasAdd };
1119
+ }