keycloakify 9.6.7 → 10.0.0-rc.1

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 (417) hide show
  1. package/account/Template.js +34 -14
  2. package/account/Template.js.map +1 -1
  3. package/account/i18n/baseMessages/de.d.ts +1 -1
  4. package/account/i18n/baseMessages/de.js +1 -1
  5. package/account/i18n/baseMessages/de.js.map +1 -1
  6. package/account/i18n/baseMessages/en.d.ts +2 -0
  7. package/account/i18n/baseMessages/en.js +2 -0
  8. package/account/i18n/baseMessages/en.js.map +1 -1
  9. package/account/i18n/baseMessages/es.d.ts +230 -0
  10. package/account/i18n/baseMessages/es.js +231 -1
  11. package/account/i18n/baseMessages/es.js.map +1 -1
  12. package/account/i18n/baseMessages/index.d.ts +353 -407
  13. package/account/i18n/baseMessages/index.js +1 -0
  14. package/account/i18n/baseMessages/index.js.map +1 -1
  15. package/account/i18n/baseMessages/pl.d.ts +115 -1
  16. package/account/i18n/baseMessages/pl.js +115 -1
  17. package/account/i18n/baseMessages/pl.js.map +1 -1
  18. package/account/i18n/baseMessages/tr.d.ts +1 -1
  19. package/account/i18n/baseMessages/tr.js +1 -1
  20. package/account/i18n/baseMessages/tr.js.map +1 -1
  21. package/account/i18n/baseMessages/uk.d.ts +337 -0
  22. package/account/i18n/baseMessages/uk.js +342 -0
  23. package/account/i18n/baseMessages/uk.js.map +1 -0
  24. package/account/i18n/baseMessages/zh-CN.d.ts +10 -0
  25. package/account/i18n/baseMessages/zh-CN.js +10 -0
  26. package/account/i18n/baseMessages/zh-CN.js.map +1 -1
  27. package/bin/constants.d.ts +0 -1
  28. package/bin/constants.js +1 -2
  29. package/bin/constants.js.map +1 -1
  30. package/bin/keycloakify/buildJars/buildJar.d.ts +14 -0
  31. package/bin/keycloakify/buildJars/buildJar.js +224 -0
  32. package/bin/keycloakify/buildJars/buildJar.js.map +1 -0
  33. package/bin/keycloakify/buildJars/buildJars.d.ts +10 -0
  34. package/bin/keycloakify/buildJars/buildJars.js +95 -0
  35. package/bin/keycloakify/buildJars/buildJars.js.map +1 -0
  36. package/bin/keycloakify/buildJars/extensionVersions.d.ts +12 -0
  37. package/bin/keycloakify/buildJars/extensionVersions.js +7 -0
  38. package/bin/keycloakify/buildJars/extensionVersions.js.map +1 -0
  39. package/bin/keycloakify/buildJars/generatePom.d.ts +13 -0
  40. package/bin/keycloakify/buildJars/generatePom.js +95 -0
  41. package/bin/keycloakify/buildJars/generatePom.js.map +1 -0
  42. package/bin/keycloakify/buildJars/getKeycloakVersionRangeForJar.d.ts +6 -0
  43. package/bin/keycloakify/buildJars/getKeycloakVersionRangeForJar.js +35 -0
  44. package/bin/keycloakify/buildJars/getKeycloakVersionRangeForJar.js.map +1 -0
  45. package/bin/keycloakify/buildJars/index.d.ts +1 -0
  46. package/bin/keycloakify/buildJars/index.js +18 -0
  47. package/bin/keycloakify/buildJars/index.js.map +1 -0
  48. package/bin/keycloakify/buildOptions/UserProvidedBuildOptions.d.ts +0 -8
  49. package/bin/keycloakify/buildOptions/UserProvidedBuildOptions.js +1 -3
  50. package/bin/keycloakify/buildOptions/UserProvidedBuildOptions.js.map +1 -1
  51. package/bin/keycloakify/buildOptions/buildOptions.d.ts +0 -2
  52. package/bin/keycloakify/buildOptions/buildOptions.js +3 -5
  53. package/bin/keycloakify/buildOptions/buildOptions.js.map +1 -1
  54. package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +105 -234
  55. package/bin/keycloakify/generateFtl/generateFtl.js +17 -39
  56. package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
  57. package/bin/keycloakify/generateFtl/pageId.d.ts +1 -1
  58. package/bin/keycloakify/generateFtl/pageId.js +11 -3
  59. package/bin/keycloakify/generateFtl/pageId.js.map +1 -1
  60. package/bin/keycloakify/generateStartKeycloakTestingContainer.d.ts +0 -1
  61. package/bin/keycloakify/generateStartKeycloakTestingContainer.js +3 -6
  62. package/bin/keycloakify/generateStartKeycloakTestingContainer.js.map +1 -1
  63. package/bin/keycloakify/generateTheme/bringInAccountV1.d.ts +1 -1
  64. package/bin/keycloakify/generateTheme/bringInAccountV1.js +5 -9
  65. package/bin/keycloakify/generateTheme/bringInAccountV1.js.map +1 -1
  66. package/bin/keycloakify/generateTheme/generateSrcMainResources.d.ts +21 -0
  67. package/bin/keycloakify/generateTheme/generateSrcMainResources.js +340 -0
  68. package/bin/keycloakify/generateTheme/generateSrcMainResources.js.map +1 -0
  69. package/bin/keycloakify/generateTheme/generateTheme.d.ts +5 -13
  70. package/bin/keycloakify/generateTheme/generateTheme.js +30 -293
  71. package/bin/keycloakify/generateTheme/generateTheme.js.map +1 -1
  72. package/bin/keycloakify/generateTheme/generateThemeVariants.d.ts +5 -0
  73. package/bin/keycloakify/generateTheme/generateThemeVariants.js +67 -0
  74. package/bin/keycloakify/generateTheme/generateThemeVariants.js.map +1 -0
  75. package/bin/keycloakify/generateTheme/readFieldNameUsage.js +53 -18
  76. package/bin/keycloakify/generateTheme/readFieldNameUsage.js.map +1 -1
  77. package/bin/keycloakify/keycloakify.js +28 -104
  78. package/bin/keycloakify/keycloakify.js.map +1 -1
  79. package/lib/useGetClassName.js +2 -2
  80. package/lib/useGetClassName.js.map +1 -1
  81. package/login/Fallback.d.ts +7 -1
  82. package/login/Fallback.js +32 -8
  83. package/login/Fallback.js.map +1 -1
  84. package/login/Template.js +76 -20
  85. package/login/Template.js.map +1 -1
  86. package/login/TemplateProps.d.ts +4 -2
  87. package/login/UserProfileFormFields.d.ts +22 -0
  88. package/login/UserProfileFormFields.js +327 -0
  89. package/login/UserProfileFormFields.js.map +1 -0
  90. package/login/i18n/baseMessages/ar.d.ts +3 -0
  91. package/login/i18n/baseMessages/ar.js +3 -0
  92. package/login/i18n/baseMessages/ar.js.map +1 -1
  93. package/login/i18n/baseMessages/ca.d.ts +1 -0
  94. package/login/i18n/baseMessages/ca.js +1 -0
  95. package/login/i18n/baseMessages/ca.js.map +1 -1
  96. package/login/i18n/baseMessages/cs.d.ts +3 -0
  97. package/login/i18n/baseMessages/cs.js +3 -0
  98. package/login/i18n/baseMessages/cs.js.map +1 -1
  99. package/login/i18n/baseMessages/da.d.ts +1 -0
  100. package/login/i18n/baseMessages/da.js +1 -0
  101. package/login/i18n/baseMessages/da.js.map +1 -1
  102. package/login/i18n/baseMessages/de.d.ts +1 -0
  103. package/login/i18n/baseMessages/de.js +1 -0
  104. package/login/i18n/baseMessages/de.js.map +1 -1
  105. package/login/i18n/baseMessages/el.d.ts +1 -0
  106. package/login/i18n/baseMessages/el.js +1 -0
  107. package/login/i18n/baseMessages/el.js.map +1 -1
  108. package/login/i18n/baseMessages/en.d.ts +7 -0
  109. package/login/i18n/baseMessages/en.js +23 -16
  110. package/login/i18n/baseMessages/en.js.map +1 -1
  111. package/login/i18n/baseMessages/es.d.ts +239 -0
  112. package/login/i18n/baseMessages/es.js +240 -1
  113. package/login/i18n/baseMessages/es.js.map +1 -1
  114. package/login/i18n/baseMessages/fa.d.ts +1 -0
  115. package/login/i18n/baseMessages/fa.js +1 -0
  116. package/login/i18n/baseMessages/fa.js.map +1 -1
  117. package/login/i18n/baseMessages/fi.d.ts +1 -0
  118. package/login/i18n/baseMessages/fi.js +1 -0
  119. package/login/i18n/baseMessages/fi.js.map +1 -1
  120. package/login/i18n/baseMessages/fr.d.ts +1 -0
  121. package/login/i18n/baseMessages/fr.js +2 -1
  122. package/login/i18n/baseMessages/fr.js.map +1 -1
  123. package/login/i18n/baseMessages/hu.d.ts +1 -0
  124. package/login/i18n/baseMessages/hu.js +1 -0
  125. package/login/i18n/baseMessages/hu.js.map +1 -1
  126. package/login/i18n/baseMessages/index.d.ts +211 -416
  127. package/login/i18n/baseMessages/index.js +1 -0
  128. package/login/i18n/baseMessages/index.js.map +1 -1
  129. package/login/i18n/baseMessages/it.d.ts +1 -0
  130. package/login/i18n/baseMessages/it.js +1 -0
  131. package/login/i18n/baseMessages/it.js.map +1 -1
  132. package/login/i18n/baseMessages/ja.d.ts +1 -0
  133. package/login/i18n/baseMessages/ja.js +1 -0
  134. package/login/i18n/baseMessages/ja.js.map +1 -1
  135. package/login/i18n/baseMessages/lt.d.ts +1 -0
  136. package/login/i18n/baseMessages/lt.js +1 -0
  137. package/login/i18n/baseMessages/lt.js.map +1 -1
  138. package/login/i18n/baseMessages/lv.d.ts +1 -0
  139. package/login/i18n/baseMessages/lv.js +1 -0
  140. package/login/i18n/baseMessages/lv.js.map +1 -1
  141. package/login/i18n/baseMessages/nl.d.ts +1 -0
  142. package/login/i18n/baseMessages/nl.js +1 -0
  143. package/login/i18n/baseMessages/nl.js.map +1 -1
  144. package/login/i18n/baseMessages/no.d.ts +1 -0
  145. package/login/i18n/baseMessages/no.js +1 -0
  146. package/login/i18n/baseMessages/no.js.map +1 -1
  147. package/login/i18n/baseMessages/pl.d.ts +1 -0
  148. package/login/i18n/baseMessages/pl.js +1 -0
  149. package/login/i18n/baseMessages/pl.js.map +1 -1
  150. package/login/i18n/baseMessages/pt-BR.d.ts +1 -0
  151. package/login/i18n/baseMessages/pt-BR.js +1 -0
  152. package/login/i18n/baseMessages/pt-BR.js.map +1 -1
  153. package/login/i18n/baseMessages/ru.d.ts +1 -0
  154. package/login/i18n/baseMessages/ru.js +1 -0
  155. package/login/i18n/baseMessages/ru.js.map +1 -1
  156. package/login/i18n/baseMessages/sk.d.ts +2 -0
  157. package/login/i18n/baseMessages/sk.js +3 -1
  158. package/login/i18n/baseMessages/sk.js.map +1 -1
  159. package/login/i18n/baseMessages/sv.d.ts +1 -0
  160. package/login/i18n/baseMessages/sv.js +1 -0
  161. package/login/i18n/baseMessages/sv.js.map +1 -1
  162. package/login/i18n/baseMessages/th.d.ts +1 -0
  163. package/login/i18n/baseMessages/th.js +1 -0
  164. package/login/i18n/baseMessages/th.js.map +1 -1
  165. package/login/i18n/baseMessages/tr.d.ts +1 -0
  166. package/login/i18n/baseMessages/tr.js +1 -0
  167. package/login/i18n/baseMessages/tr.js.map +1 -1
  168. package/login/i18n/baseMessages/uk.d.ts +433 -0
  169. package/login/i18n/baseMessages/uk.js +438 -0
  170. package/login/i18n/baseMessages/uk.js.map +1 -0
  171. package/login/i18n/baseMessages/zh-CN.d.ts +273 -3
  172. package/login/i18n/baseMessages/zh-CN.js +325 -55
  173. package/login/i18n/baseMessages/zh-CN.js.map +1 -1
  174. package/login/i18n/i18n.d.ts +4 -0
  175. package/login/i18n/i18n.js +6 -2
  176. package/login/i18n/i18n.js.map +1 -1
  177. package/login/kcContext/KcContext.d.ts +181 -105
  178. package/login/kcContext/KcContext.js +1 -1
  179. package/login/kcContext/KcContext.js.map +1 -1
  180. package/login/kcContext/createGetKcContext.js +3 -9
  181. package/login/kcContext/createGetKcContext.js.map +1 -1
  182. package/login/kcContext/kcContextMocks.d.ts +1 -1
  183. package/login/kcContext/kcContextMocks.js +92 -198
  184. package/login/kcContext/kcContextMocks.js.map +1 -1
  185. package/login/lib/useDownloadTerms.d.ts +4 -1
  186. package/login/lib/useDownloadTerms.js +9 -4
  187. package/login/lib/useDownloadTerms.js.map +1 -1
  188. package/login/lib/useGetClassName.js +112 -73
  189. package/login/lib/useGetClassName.js.map +1 -1
  190. package/login/lib/useUserProfileForm.d.ts +74 -0
  191. package/login/lib/useUserProfileForm.js +868 -0
  192. package/login/lib/useUserProfileForm.js.map +1 -0
  193. package/login/pages/{UpdateUserProfile.d.ts → Code.d.ts} +2 -2
  194. package/login/pages/Code.js +13 -0
  195. package/login/pages/Code.js.map +1 -0
  196. package/login/pages/DeleteAccountConfirm.d.ts +7 -0
  197. package/login/pages/DeleteAccountConfirm.js +14 -0
  198. package/login/pages/DeleteAccountConfirm.js.map +1 -0
  199. package/login/pages/{RegisterUserProfile.d.ts → DeleteCredential.d.ts} +2 -2
  200. package/login/pages/DeleteCredential.js +14 -0
  201. package/login/pages/DeleteCredential.js.map +1 -0
  202. package/login/pages/Error.js +2 -2
  203. package/login/pages/Error.js.map +1 -1
  204. package/login/pages/FrontchannelLogout.d.ts +7 -0
  205. package/login/pages/FrontchannelLogout.js +14 -0
  206. package/login/pages/FrontchannelLogout.js.map +1 -0
  207. package/login/pages/IdpReviewUserProfile.d.ts +8 -2
  208. package/login/pages/IdpReviewUserProfile.js +3 -4
  209. package/login/pages/IdpReviewUserProfile.js.map +1 -1
  210. package/login/pages/Info.js +14 -1
  211. package/login/pages/Info.js.map +1 -1
  212. package/login/pages/Login.js +24 -38
  213. package/login/pages/Login.js.map +1 -1
  214. package/login/pages/LoginConfigTotp.js +8 -1
  215. package/login/pages/LoginConfigTotp.js.map +1 -1
  216. package/login/pages/{LoginDeviceVerifyUserCode.d.ts → LoginOauth2DeviceVerifyUserCode.d.ts} +1 -1
  217. package/login/pages/{LoginDeviceVerifyUserCode.js → LoginOauth2DeviceVerifyUserCode.js} +2 -2
  218. package/login/pages/LoginOauth2DeviceVerifyUserCode.js.map +1 -0
  219. package/login/pages/LoginOauthGrant.js +3 -2
  220. package/login/pages/LoginOauthGrant.js.map +1 -1
  221. package/login/pages/LoginOtp.js +4 -6
  222. package/login/pages/LoginOtp.js.map +1 -1
  223. package/login/pages/LoginPageExpired.js +1 -1
  224. package/login/pages/LoginPageExpired.js.map +1 -1
  225. package/login/pages/LoginPassword.d.ts +1 -1
  226. package/login/pages/LoginPassword.js +18 -11
  227. package/login/pages/LoginPassword.js.map +1 -1
  228. package/login/pages/LoginRecoveryAuthnCodeConfig.d.ts +7 -0
  229. package/login/pages/LoginRecoveryAuthnCodeConfig.js +147 -0
  230. package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -0
  231. package/login/pages/LoginRecoveryAuthnCodeInput.d.ts +7 -0
  232. package/login/pages/LoginRecoveryAuthnCodeInput.js +14 -0
  233. package/login/pages/LoginRecoveryAuthnCodeInput.js.map +1 -0
  234. package/login/pages/LoginResetOtp.d.ts +7 -0
  235. package/login/pages/LoginResetOtp.js +15 -0
  236. package/login/pages/LoginResetOtp.js.map +1 -0
  237. package/login/pages/LoginResetPassword.js +4 -3
  238. package/login/pages/LoginResetPassword.js.map +1 -1
  239. package/login/pages/LoginUpdatePassword.js +21 -3
  240. package/login/pages/LoginUpdatePassword.js.map +1 -1
  241. package/login/pages/LoginUpdateProfile.d.ts +8 -2
  242. package/login/pages/LoginUpdateProfile.js +11 -5
  243. package/login/pages/LoginUpdateProfile.js.map +1 -1
  244. package/login/pages/LoginUsername.js +11 -35
  245. package/login/pages/LoginUsername.js.map +1 -1
  246. package/login/pages/LoginVerifyEmail.js +1 -1
  247. package/login/pages/LoginVerifyEmail.js.map +1 -1
  248. package/login/pages/LoginX509Info.d.ts +7 -0
  249. package/login/pages/LoginX509Info.js +14 -0
  250. package/login/pages/LoginX509Info.js.map +1 -0
  251. package/login/pages/LogoutConfirm.js +1 -1
  252. package/login/pages/LogoutConfirm.js.map +1 -1
  253. package/login/pages/Register.d.ts +8 -2
  254. package/login/pages/Register.js +26 -4
  255. package/login/pages/Register.js.map +1 -1
  256. package/login/pages/SamlPostForm.js +1 -1
  257. package/login/pages/SamlPostForm.js.map +1 -1
  258. package/login/pages/SelectAuthenticator.js +5 -21
  259. package/login/pages/SelectAuthenticator.js.map +1 -1
  260. package/login/pages/Terms.js +4 -6
  261. package/login/pages/Terms.js.map +1 -1
  262. package/login/pages/UpdateEmail.d.ts +8 -2
  263. package/login/pages/UpdateEmail.js +16 -5
  264. package/login/pages/UpdateEmail.js.map +1 -1
  265. package/login/pages/WebauthnAuthenticate.js +121 -83
  266. package/login/pages/WebauthnAuthenticate.js.map +1 -1
  267. package/login/pages/WebauthnError.d.ts +7 -0
  268. package/login/pages/WebauthnError.js +21 -0
  269. package/login/pages/WebauthnError.js.map +1 -0
  270. package/login/pages/WebauthnRegister.d.ts +7 -0
  271. package/login/pages/WebauthnRegister.js +193 -0
  272. package/login/pages/WebauthnRegister.js.map +1 -0
  273. package/package.json +138 -43
  274. package/src/account/Template.tsx +41 -14
  275. package/src/account/i18n/baseMessages/de.ts +1 -1
  276. package/src/account/i18n/baseMessages/en.ts +2 -0
  277. package/src/account/i18n/baseMessages/es.ts +231 -1
  278. package/src/account/i18n/baseMessages/index.ts +1 -0
  279. package/src/account/i18n/baseMessages/pl.ts +115 -1
  280. package/src/account/i18n/baseMessages/tr.ts +1 -1
  281. package/src/account/i18n/baseMessages/uk.ts +343 -0
  282. package/src/account/i18n/baseMessages/zh-CN.ts +10 -0
  283. package/src/bin/constants.ts +0 -1
  284. package/src/bin/keycloakify/buildJars/buildJar.ts +174 -0
  285. package/src/bin/keycloakify/buildJars/buildJars.ts +62 -0
  286. package/src/bin/keycloakify/buildJars/extensionVersions.ts +16 -0
  287. package/src/bin/keycloakify/buildJars/generatePom.ts +86 -0
  288. package/src/bin/keycloakify/buildJars/getKeycloakVersionRangeForJar.ts +37 -0
  289. package/src/bin/keycloakify/buildJars/index.ts +1 -0
  290. package/src/bin/keycloakify/buildOptions/UserProvidedBuildOptions.ts +1 -5
  291. package/src/bin/keycloakify/buildOptions/buildOptions.ts +1 -5
  292. package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +105 -234
  293. package/src/bin/keycloakify/generateFtl/generateFtl.ts +15 -31
  294. package/src/bin/keycloakify/generateFtl/pageId.ts +11 -3
  295. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +4 -8
  296. package/src/bin/keycloakify/generateTheme/bringInAccountV1.ts +5 -11
  297. package/src/bin/keycloakify/generateTheme/generateSrcMainResources.ts +267 -0
  298. package/src/bin/keycloakify/generateTheme/generateTheme.ts +22 -309
  299. package/src/bin/keycloakify/generateTheme/generateThemeVariants.ts +50 -0
  300. package/src/bin/keycloakify/generateTheme/readFieldNameUsage.ts +31 -8
  301. package/src/bin/keycloakify/keycloakify.ts +23 -56
  302. package/src/lib/useGetClassName.ts +2 -2
  303. package/src/login/Fallback.tsx +39 -9
  304. package/src/login/Template.tsx +160 -61
  305. package/src/login/TemplateProps.ts +113 -63
  306. package/src/login/UserProfileFormFields.tsx +750 -0
  307. package/src/login/i18n/baseMessages/ar.ts +3 -0
  308. package/src/login/i18n/baseMessages/ca.ts +1 -0
  309. package/src/login/i18n/baseMessages/cs.ts +3 -0
  310. package/src/login/i18n/baseMessages/da.ts +1 -0
  311. package/src/login/i18n/baseMessages/de.ts +1 -0
  312. package/src/login/i18n/baseMessages/el.ts +1 -0
  313. package/src/login/i18n/baseMessages/en.ts +23 -16
  314. package/src/login/i18n/baseMessages/es.ts +240 -1
  315. package/src/login/i18n/baseMessages/fa.ts +1 -0
  316. package/src/login/i18n/baseMessages/fi.ts +1 -0
  317. package/src/login/i18n/baseMessages/fr.ts +2 -1
  318. package/src/login/i18n/baseMessages/hu.ts +1 -0
  319. package/src/login/i18n/baseMessages/index.ts +1 -0
  320. package/src/login/i18n/baseMessages/it.ts +1 -0
  321. package/src/login/i18n/baseMessages/ja.ts +1 -0
  322. package/src/login/i18n/baseMessages/lt.ts +1 -0
  323. package/src/login/i18n/baseMessages/lv.ts +1 -0
  324. package/src/login/i18n/baseMessages/nl.ts +1 -0
  325. package/src/login/i18n/baseMessages/no.ts +1 -0
  326. package/src/login/i18n/baseMessages/pl.ts +1 -0
  327. package/src/login/i18n/baseMessages/pt-BR.ts +1 -0
  328. package/src/login/i18n/baseMessages/ru.ts +1 -0
  329. package/src/login/i18n/baseMessages/sk.ts +3 -1
  330. package/src/login/i18n/baseMessages/sv.ts +1 -0
  331. package/src/login/i18n/baseMessages/th.ts +1 -0
  332. package/src/login/i18n/baseMessages/tr.ts +1 -0
  333. package/src/login/i18n/baseMessages/uk.ts +439 -0
  334. package/src/login/i18n/baseMessages/zh-CN.ts +325 -55
  335. package/src/login/i18n/i18n.tsx +6 -2
  336. package/src/login/kcContext/KcContext.ts +216 -103
  337. package/src/login/kcContext/createGetKcContext.ts +11 -19
  338. package/src/login/kcContext/kcContextMocks.ts +165 -226
  339. package/src/login/lib/useDownloadTerms.ts +15 -7
  340. package/src/login/lib/useGetClassName.ts +112 -83
  341. package/src/login/lib/useUserProfileForm.tsx +1227 -0
  342. package/src/login/pages/Code.tsx +35 -0
  343. package/src/login/pages/DeleteAccountConfirm.tsx +53 -0
  344. package/src/login/pages/DeleteCredential.tsx +45 -0
  345. package/src/login/pages/Error.tsx +2 -2
  346. package/src/login/pages/FrontchannelLogout.tsx +41 -0
  347. package/src/login/pages/IdpReviewUserProfile.tsx +15 -5
  348. package/src/login/pages/Info.tsx +29 -19
  349. package/src/login/pages/Login.tsx +156 -117
  350. package/src/login/pages/LoginConfigTotp.tsx +26 -1
  351. package/src/login/pages/{LoginDeviceVerifyUserCode.tsx → LoginOauth2DeviceVerifyUserCode.tsx} +3 -1
  352. package/src/login/pages/LoginOauthGrant.tsx +38 -2
  353. package/src/login/pages/LoginOtp.tsx +73 -65
  354. package/src/login/pages/LoginPageExpired.tsx +1 -1
  355. package/src/login/pages/LoginPassword.tsx +77 -28
  356. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +260 -0
  357. package/src/login/pages/LoginRecoveryAuthnCodeInput.tsx +73 -0
  358. package/src/login/pages/LoginResetOtp.tsx +70 -0
  359. package/src/login/pages/LoginResetPassword.tsx +11 -4
  360. package/src/login/pages/LoginUpdatePassword.tsx +120 -81
  361. package/src/login/pages/LoginUpdateProfile.tsx +41 -115
  362. package/src/login/pages/LoginUsername.tsx +93 -101
  363. package/src/login/pages/LoginVerifyEmail.tsx +14 -8
  364. package/src/login/pages/LoginX509Info.tsx +94 -0
  365. package/src/login/pages/LogoutConfirm.tsx +2 -2
  366. package/src/login/pages/Register.tsx +83 -131
  367. package/src/login/pages/SamlPostForm.tsx +1 -1
  368. package/src/login/pages/SelectAuthenticator.tsx +29 -52
  369. package/src/login/pages/Terms.tsx +4 -7
  370. package/src/login/pages/UpdateEmail.tsx +69 -54
  371. package/src/login/pages/WebauthnAuthenticate.tsx +205 -165
  372. package/src/login/pages/WebauthnError.tsx +66 -0
  373. package/src/login/pages/WebauthnRegister.tsx +285 -0
  374. package/src/tools/formatNumber.ts +48 -0
  375. package/src/tools/useInsertLinkTags.ts +82 -0
  376. package/src/tools/useInsertScriptTags.ts +106 -0
  377. package/src/tools/useSetClassName.ts +21 -0
  378. package/tools/formatNumber.d.ts +1 -0
  379. package/tools/formatNumber.js +37 -0
  380. package/tools/formatNumber.js.map +1 -0
  381. package/tools/useInsertLinkTags.d.ts +7 -0
  382. package/tools/useInsertLinkTags.js +57 -0
  383. package/tools/useInsertLinkTags.js.map +1 -0
  384. package/tools/useInsertScriptTags.d.ts +20 -0
  385. package/tools/useInsertScriptTags.js +75 -0
  386. package/tools/useInsertScriptTags.js.map +1 -0
  387. package/tools/useSetClassName.d.ts +4 -0
  388. package/tools/useSetClassName.js +16 -0
  389. package/tools/useSetClassName.js.map +1 -0
  390. package/vite-plugin/tsconfig.tsbuildinfo +1 -1
  391. package/bin/keycloakify/generatePom.d.ts +0 -12
  392. package/bin/keycloakify/generatePom.js +0 -59
  393. package/bin/keycloakify/generatePom.js.map +0 -1
  394. package/lib/usePrepareTemplate.d.ts +0 -11
  395. package/lib/usePrepareTemplate.js +0 -80
  396. package/lib/usePrepareTemplate.js.map +0 -1
  397. package/login/lib/useFormValidation.d.ts +0 -47
  398. package/login/lib/useFormValidation.js +0 -316
  399. package/login/lib/useFormValidation.js.map +0 -1
  400. package/login/pages/LoginDeviceVerifyUserCode.js.map +0 -1
  401. package/login/pages/RegisterUserProfile.js +0 -18
  402. package/login/pages/RegisterUserProfile.js.map +0 -1
  403. package/login/pages/UpdateUserProfile.js +0 -17
  404. package/login/pages/UpdateUserProfile.js.map +0 -1
  405. package/login/pages/shared/UserProfileFormFields.d.ts +0 -18
  406. package/login/pages/shared/UserProfileFormFields.js +0 -58
  407. package/login/pages/shared/UserProfileFormFields.js.map +0 -1
  408. package/src/bin/keycloakify/generatePom.ts +0 -70
  409. package/src/lib/usePrepareTemplate.ts +0 -113
  410. package/src/login/lib/useFormValidation.tsx +0 -474
  411. package/src/login/pages/RegisterUserProfile.tsx +0 -72
  412. package/src/login/pages/UpdateUserProfile.tsx +0 -82
  413. package/src/login/pages/shared/UserProfileFormFields.tsx +0 -177
  414. package/src/tools/headInsert.ts +0 -73
  415. package/tools/headInsert.d.ts +0 -12
  416. package/tools/headInsert.js +0 -50
  417. package/tools/headInsert.js.map +0 -1
@@ -0,0 +1,868 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import "../../tools/Array.prototype.every";
14
+ import { useMemo, useReducer, useEffect, Fragment } from "react";
15
+ import { id } from "tsafe/id";
16
+ import { useConstCallback } from "../../tools/useConstCallback";
17
+ import { emailRegexp } from "../../tools/emailRegExp";
18
+ import { assert } from "tsafe/assert";
19
+ import { formatNumber } from "../../tools/formatNumber";
20
+ import { createUseInsertScriptTags } from "../../tools/useInsertScriptTags";
21
+ const { useInsertScriptTags } = createUseInsertScriptTags();
22
+ export function useUserProfileForm(params) {
23
+ var _a, _b;
24
+ const { kcContext, i18n, doMakeUserConfirmPassword } = params;
25
+ const { insertScriptTags } = useInsertScriptTags({
26
+ "scriptTags": Object.keys((_b = (_a = kcContext.profile) === null || _a === void 0 ? void 0 : _a.html5DataAnnotations) !== null && _b !== void 0 ? _b : {})
27
+ .filter(key => key !== "kcMultivalued" && key !== "kcNumberFormat") // NOTE: Keycloakify handles it.
28
+ .map(key => ({
29
+ "type": "module",
30
+ "src": `${kcContext.url.resourcesPath}/js/${key}.js`
31
+ }))
32
+ });
33
+ useEffect(() => {
34
+ insertScriptTags();
35
+ }, []);
36
+ const { getErrors } = useGetErrors({
37
+ kcContext,
38
+ i18n
39
+ });
40
+ const initialState = useMemo(() => {
41
+ // NOTE: We don't use te kcContext.profile.attributes directly because
42
+ // they don't includes the password and password confirm fields and we want to add them.
43
+ // Also, we want to polyfill the attributes for older Keycloak version before User Profile was introduced.
44
+ // Finally we want to patch the changes made by Keycloak on the attributes format so we have an homogeneous
45
+ // attributes format to work with.
46
+ const syntheticAttributes = (() => {
47
+ const syntheticAttributes = [];
48
+ const attributes = (() => {
49
+ var _a;
50
+ retrocompat_patch: {
51
+ if ("profile" in kcContext && "attributes" in kcContext.profile && kcContext.profile.attributes.length !== 0) {
52
+ break retrocompat_patch;
53
+ }
54
+ if ("register" in kcContext && kcContext.register instanceof Object && "formData" in kcContext.register) {
55
+ //NOTE: Handle legacy register.ftl page
56
+ return ["firstName", "lastName", "email", "username"]
57
+ .filter(name => (name !== "username" ? true : !kcContext.realm.registrationEmailAsUsername))
58
+ .map(name => {
59
+ var _a;
60
+ return id({
61
+ "name": name,
62
+ "displayName": id(`\${${name}}`),
63
+ "required": true,
64
+ "value": (_a = kcContext.register.formData[name]) !== null && _a !== void 0 ? _a : "",
65
+ "html5DataAnnotations": {},
66
+ "readOnly": false,
67
+ "validators": {},
68
+ "annotations": {},
69
+ "autocomplete": (() => {
70
+ switch (name) {
71
+ case "email":
72
+ return "email";
73
+ case "username":
74
+ return "username";
75
+ default:
76
+ return undefined;
77
+ }
78
+ })()
79
+ });
80
+ });
81
+ }
82
+ if ("user" in kcContext && kcContext.user instanceof Object) {
83
+ //NOTE: Handle legacy login-update-profile.ftl
84
+ return ["username", "email", "firstName", "lastName"]
85
+ .filter(name => (name !== "username" ? true : kcContext.user.editUsernameAllowed))
86
+ .map(name => {
87
+ var _a;
88
+ return id({
89
+ "name": name,
90
+ "displayName": id(`\${${name}}`),
91
+ "required": true,
92
+ "value": (_a = kcContext.user[name]) !== null && _a !== void 0 ? _a : "",
93
+ "html5DataAnnotations": {},
94
+ "readOnly": false,
95
+ "validators": {},
96
+ "annotations": {},
97
+ "autocomplete": (() => {
98
+ switch (name) {
99
+ case "email":
100
+ return "email";
101
+ case "username":
102
+ return "username";
103
+ default:
104
+ return undefined;
105
+ }
106
+ })()
107
+ });
108
+ });
109
+ }
110
+ if ("email" in kcContext && kcContext.email instanceof Object) {
111
+ //NOTE: Handle legacy update-email.ftl
112
+ return [
113
+ id({
114
+ "name": "email",
115
+ "displayName": id(`\${email}`),
116
+ "required": true,
117
+ "value": (_a = kcContext.email.value) !== null && _a !== void 0 ? _a : "",
118
+ "html5DataAnnotations": {},
119
+ "readOnly": false,
120
+ "validators": {},
121
+ "annotations": {},
122
+ "autocomplete": "email"
123
+ })
124
+ ];
125
+ }
126
+ assert(false, "Unable to mock user profile from the current kcContext");
127
+ }
128
+ return kcContext.profile.attributes.map(attribute_pre_group_patch => {
129
+ if (typeof attribute_pre_group_patch.group === "string" && attribute_pre_group_patch.group !== "") {
130
+ const _a = attribute_pre_group_patch, { group, groupDisplayHeader, groupDisplayDescription, groupAnnotations } = _a, rest = __rest(_a, ["group", "groupDisplayHeader", "groupDisplayDescription", "groupAnnotations"]);
131
+ return id(Object.assign(Object.assign({}, rest), { "group": {
132
+ "name": group,
133
+ "displayHeader": groupDisplayHeader,
134
+ "displayDescription": groupDisplayDescription,
135
+ "html5DataAnnotations": {}
136
+ } }));
137
+ }
138
+ return attribute_pre_group_patch;
139
+ });
140
+ })();
141
+ for (const attribute of attributes) {
142
+ syntheticAttributes.push(attribute);
143
+ add_password_and_password_confirm: {
144
+ if (!kcContext.passwordRequired) {
145
+ break add_password_and_password_confirm;
146
+ }
147
+ if (attribute.name !== (kcContext.realm.registrationEmailAsUsername ? "email" : "username")) {
148
+ // NOTE: We want to add password and password-confirm after the field that identifies the user.
149
+ // It's either email or username.
150
+ break add_password_and_password_confirm;
151
+ }
152
+ syntheticAttributes.push(Object.assign({ "name": "password", "displayName": id("${password}"), "required": true, "readOnly": false, "validators": {}, "annotations": {}, "autocomplete": "new-password", "html5DataAnnotations": {} }, { "groupAnnotations": {} }), Object.assign({ "name": "password-confirm", "displayName": id("${passwordConfirm}"), "required": true, "readOnly": false, "validators": {}, "annotations": {}, "html5DataAnnotations": {}, "autocomplete": "new-password" }, { "groupAnnotations": {} }));
153
+ }
154
+ }
155
+ return syntheticAttributes;
156
+ })();
157
+ const initialFormFieldState = (() => {
158
+ var _a, _b, _c;
159
+ const out = [];
160
+ for (const attribute of syntheticAttributes) {
161
+ handle_multi_valued_attribute: {
162
+ if (!attribute.multivalued) {
163
+ break handle_multi_valued_attribute;
164
+ }
165
+ const values = (_a = attribute.values) !== null && _a !== void 0 ? _a : [""];
166
+ apply_validator_min_range: {
167
+ if ((_b = attribute.annotations.inputType) === null || _b === void 0 ? void 0 : _b.startsWith("multiselect")) {
168
+ break apply_validator_min_range;
169
+ }
170
+ const validator = attribute.validators.multivalued;
171
+ if (validator === undefined) {
172
+ break apply_validator_min_range;
173
+ }
174
+ const { min: minStr } = validator;
175
+ if (minStr === undefined) {
176
+ break apply_validator_min_range;
177
+ }
178
+ const min = parseInt(`${minStr}`);
179
+ for (let index = values.length; index < min; index++) {
180
+ values.push("");
181
+ }
182
+ }
183
+ out.push({
184
+ attribute,
185
+ "valueOrValues": values
186
+ });
187
+ continue;
188
+ }
189
+ out.push({
190
+ attribute,
191
+ "valueOrValues": (_c = attribute.value) !== null && _c !== void 0 ? _c : ""
192
+ });
193
+ }
194
+ return out;
195
+ })();
196
+ const initialState = {
197
+ "formFieldStates": initialFormFieldState.map(({ attribute, valueOrValues }) => ({
198
+ attribute,
199
+ "errors": getErrors({
200
+ "attributeName": attribute.name,
201
+ "formFieldStates": initialFormFieldState
202
+ }),
203
+ "hasLostFocusAtLeastOnce": valueOrValues instanceof Array ? valueOrValues.map(() => false) : false,
204
+ "valueOrValues": valueOrValues
205
+ }))
206
+ };
207
+ return initialState;
208
+ }, []);
209
+ const [state, dispatchFormAction] = useReducer(function reducer(state, params) {
210
+ const formFieldState = state.formFieldStates.find(({ attribute }) => attribute.name === params.name);
211
+ assert(formFieldState !== undefined);
212
+ (() => {
213
+ var _a;
214
+ switch (params.action) {
215
+ case "update":
216
+ formFieldState.valueOrValues = params.valueOrValues;
217
+ apply_formatters: {
218
+ const { attribute } = formFieldState;
219
+ const { kcNumberFormat } = (_a = attribute.html5DataAnnotations) !== null && _a !== void 0 ? _a : {};
220
+ if (kcNumberFormat === undefined) {
221
+ break apply_formatters;
222
+ }
223
+ if (formFieldState.valueOrValues instanceof Array) {
224
+ formFieldState.valueOrValues = formFieldState.valueOrValues.map(value => formatNumber(value, kcNumberFormat));
225
+ }
226
+ else {
227
+ formFieldState.valueOrValues = formatNumber(formFieldState.valueOrValues, kcNumberFormat);
228
+ }
229
+ }
230
+ formFieldState.errors = getErrors({
231
+ "attributeName": params.name,
232
+ "formFieldStates": state.formFieldStates
233
+ });
234
+ update_password_confirm: {
235
+ if (doMakeUserConfirmPassword) {
236
+ break update_password_confirm;
237
+ }
238
+ if (params.name !== "password") {
239
+ break update_password_confirm;
240
+ }
241
+ state = reducer(state, {
242
+ "action": "update",
243
+ "name": "password-confirm",
244
+ "valueOrValues": params.valueOrValues
245
+ });
246
+ }
247
+ return;
248
+ case "focus lost":
249
+ if (formFieldState.hasLostFocusAtLeastOnce instanceof Array) {
250
+ const { fieldIndex } = params;
251
+ assert(fieldIndex !== undefined);
252
+ formFieldState.hasLostFocusAtLeastOnce[fieldIndex] = true;
253
+ return;
254
+ }
255
+ formFieldState.hasLostFocusAtLeastOnce = true;
256
+ return;
257
+ }
258
+ assert(false);
259
+ })();
260
+ return state;
261
+ }, initialState);
262
+ const formState = useMemo(() => ({
263
+ "formFieldStates": state.formFieldStates.map((_a) => {
264
+ var { errors, hasLostFocusAtLeastOnce: hasLostFocusAtLeastOnceOrArr, attribute } = _a, valueOrValuesWrap = __rest(_a, ["errors", "hasLostFocusAtLeastOnce", "attribute"]);
265
+ return (Object.assign({ "displayableErrors": errors.filter(error => {
266
+ const hasLostFocusAtLeastOnce = typeof hasLostFocusAtLeastOnceOrArr === "boolean"
267
+ ? hasLostFocusAtLeastOnceOrArr
268
+ : error.fieldIndex !== undefined
269
+ ? hasLostFocusAtLeastOnceOrArr[error.fieldIndex]
270
+ : hasLostFocusAtLeastOnceOrArr[hasLostFocusAtLeastOnceOrArr.length - 1];
271
+ switch (error.source.type) {
272
+ case "server":
273
+ return true;
274
+ case "other":
275
+ switch (error.source.rule) {
276
+ case "requiredField":
277
+ return hasLostFocusAtLeastOnce;
278
+ case "passwordConfirmMatchesPassword":
279
+ return hasLostFocusAtLeastOnce;
280
+ }
281
+ assert(false);
282
+ case "passwordPolicy":
283
+ switch (error.source.name) {
284
+ case "length":
285
+ return hasLostFocusAtLeastOnce;
286
+ case "digits":
287
+ return hasLostFocusAtLeastOnce;
288
+ case "lowerCase":
289
+ return hasLostFocusAtLeastOnce;
290
+ case "upperCase":
291
+ return hasLostFocusAtLeastOnce;
292
+ case "specialChars":
293
+ return hasLostFocusAtLeastOnce;
294
+ case "notUsername":
295
+ return true;
296
+ case "notEmail":
297
+ return true;
298
+ }
299
+ assert(false);
300
+ case "validator":
301
+ switch (error.source.name) {
302
+ case "length":
303
+ return hasLostFocusAtLeastOnce;
304
+ case "pattern":
305
+ return hasLostFocusAtLeastOnce;
306
+ case "email":
307
+ return hasLostFocusAtLeastOnce;
308
+ case "integer":
309
+ return hasLostFocusAtLeastOnce;
310
+ case "multivalued":
311
+ return hasLostFocusAtLeastOnce;
312
+ case "options":
313
+ return hasLostFocusAtLeastOnce;
314
+ }
315
+ assert(false);
316
+ }
317
+ }), attribute }, valueOrValuesWrap));
318
+ }),
319
+ "isFormSubmittable": state.formFieldStates.every(({ errors }) => errors.length === 0)
320
+ }), [state]);
321
+ return {
322
+ formState,
323
+ dispatchFormAction
324
+ };
325
+ }
326
+ function useGetErrors(params) {
327
+ const { kcContext, i18n } = params;
328
+ const { messagesPerField, passwordPolicies } = kcContext;
329
+ const { msg, msgStr, advancedMsg, advancedMsgStr } = i18n;
330
+ const getErrors = useConstCallback((params) => {
331
+ var _a, _b, _c, _d;
332
+ const { attributeName, formFieldStates } = params;
333
+ const formFieldState = formFieldStates.find(({ attribute }) => attribute.name === attributeName);
334
+ assert(formFieldState !== undefined);
335
+ const { attribute } = formFieldState;
336
+ const valueOrValues = (() => {
337
+ var _a;
338
+ let { valueOrValues } = formFieldState;
339
+ unFormat_number: {
340
+ const { kcNumberUnFormat } = (_a = attribute.html5DataAnnotations) !== null && _a !== void 0 ? _a : {};
341
+ if (kcNumberUnFormat === undefined) {
342
+ break unFormat_number;
343
+ }
344
+ if (valueOrValues instanceof Array) {
345
+ valueOrValues = valueOrValues.map(value => formatNumber(value, kcNumberUnFormat));
346
+ }
347
+ else {
348
+ valueOrValues = formatNumber(valueOrValues, kcNumberUnFormat);
349
+ }
350
+ }
351
+ return valueOrValues;
352
+ })();
353
+ assert(attribute !== undefined);
354
+ server_side_error: {
355
+ if (attribute.multivalued) {
356
+ const defaultValues = (_a = attribute.values) !== null && _a !== void 0 ? _a : [""];
357
+ assert(valueOrValues instanceof Array);
358
+ const values = valueOrValues;
359
+ if (JSON.stringify(defaultValues) !== JSON.stringify(values.slice(0, defaultValues.length))) {
360
+ break server_side_error;
361
+ }
362
+ }
363
+ else {
364
+ const defaultValue = (_b = attribute.value) !== null && _b !== void 0 ? _b : "";
365
+ assert(typeof valueOrValues === "string");
366
+ const value = valueOrValues;
367
+ if (defaultValue !== value) {
368
+ break server_side_error;
369
+ }
370
+ }
371
+ let doesErrorExist;
372
+ try {
373
+ doesErrorExist = messagesPerField.existsError(attributeName);
374
+ }
375
+ catch (_e) {
376
+ break server_side_error;
377
+ }
378
+ if (!doesErrorExist) {
379
+ break server_side_error;
380
+ }
381
+ const errorMessageStr = messagesPerField.get(attributeName);
382
+ return [
383
+ {
384
+ errorMessageStr,
385
+ "errorMessage": _jsx("span", { children: errorMessageStr }, 0),
386
+ "fieldIndex": undefined,
387
+ "source": {
388
+ "type": "server"
389
+ }
390
+ }
391
+ ];
392
+ }
393
+ handle_multi_valued_multi_fields: {
394
+ if (!attribute.multivalued) {
395
+ break handle_multi_valued_multi_fields;
396
+ }
397
+ if ((_c = attribute.annotations.inputType) === null || _c === void 0 ? void 0 : _c.startsWith("multiselect")) {
398
+ break handle_multi_valued_multi_fields;
399
+ }
400
+ assert(valueOrValues instanceof Array);
401
+ const values = valueOrValues;
402
+ const errors = values
403
+ .map((...[, index]) => {
404
+ const specificValueErrors = getErrors({
405
+ attributeName,
406
+ "formFieldStates": formFieldStates.map(formFieldState => {
407
+ if (formFieldState.attribute.name === attributeName) {
408
+ assert(formFieldState.valueOrValues instanceof Array);
409
+ return {
410
+ "attribute": Object.assign(Object.assign({}, attribute), { "annotations": Object.assign(Object.assign({}, attribute.annotations), { "inputType": undefined }), "multivalued": false }),
411
+ "valueOrValues": formFieldState.valueOrValues[index]
412
+ };
413
+ }
414
+ return formFieldState;
415
+ })
416
+ });
417
+ return specificValueErrors
418
+ .filter(error => {
419
+ if (error.source.type === "other" && error.source.rule === "requiredField") {
420
+ return false;
421
+ }
422
+ return true;
423
+ })
424
+ .map((error) => (Object.assign(Object.assign({}, error), { "fieldIndex": index })));
425
+ })
426
+ .reduce((acc, errors) => [...acc, ...errors], []);
427
+ required_field: {
428
+ if (!attribute.required) {
429
+ break required_field;
430
+ }
431
+ if (values.every(value => value !== "")) {
432
+ break required_field;
433
+ }
434
+ const msgArgs = ["error-user-attribute-required"];
435
+ errors.push({
436
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
437
+ "errorMessageStr": msgStr(...msgArgs),
438
+ "fieldIndex": undefined,
439
+ "source": {
440
+ "type": "other",
441
+ "rule": "requiredField"
442
+ }
443
+ });
444
+ }
445
+ return errors;
446
+ }
447
+ handle_multi_valued_single_field: {
448
+ if (!attribute.multivalued) {
449
+ break handle_multi_valued_single_field;
450
+ }
451
+ if (!((_d = attribute.annotations.inputType) === null || _d === void 0 ? void 0 : _d.startsWith("multiselect"))) {
452
+ break handle_multi_valued_single_field;
453
+ }
454
+ const validatorName = "multivalued";
455
+ const validator = attribute.validators[validatorName];
456
+ if (validator === undefined) {
457
+ return [];
458
+ }
459
+ const { min: minStr } = validator;
460
+ const min = minStr !== undefined ? parseInt(`${minStr}`) : attribute.required ? 1 : 0;
461
+ assert(!isNaN(min));
462
+ const { max: maxStr } = validator;
463
+ const max = maxStr === undefined ? Infinity : parseInt(`${maxStr}`);
464
+ assert(!isNaN(max));
465
+ assert(valueOrValues instanceof Array);
466
+ const values = valueOrValues;
467
+ if (min <= values.length && values.length <= max) {
468
+ return [];
469
+ }
470
+ const msgArgs = ["error-invalid-multivalued-size", `${min}`, `${max}`];
471
+ return [
472
+ {
473
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, 0),
474
+ "errorMessageStr": msgStr(...msgArgs),
475
+ "fieldIndex": undefined,
476
+ "source": {
477
+ "type": "validator",
478
+ "name": validatorName
479
+ }
480
+ }
481
+ ];
482
+ }
483
+ assert(typeof valueOrValues === "string");
484
+ const value = valueOrValues;
485
+ const errors = [];
486
+ check_password_policies: {
487
+ if (attributeName !== "password") {
488
+ break check_password_policies;
489
+ }
490
+ if (passwordPolicies === undefined) {
491
+ break check_password_policies;
492
+ }
493
+ check_password_policy_x: {
494
+ const policyName = "length";
495
+ const policy = passwordPolicies[policyName];
496
+ if (policy === undefined) {
497
+ break check_password_policy_x;
498
+ }
499
+ const minLength = policy;
500
+ if (value.length >= minLength) {
501
+ break check_password_policy_x;
502
+ }
503
+ const msgArgs = ["invalidPasswordMinLengthMessage", `${minLength}`];
504
+ errors.push({
505
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
506
+ "errorMessageStr": msgStr(...msgArgs),
507
+ "fieldIndex": undefined,
508
+ "source": {
509
+ "type": "passwordPolicy",
510
+ "name": policyName
511
+ }
512
+ });
513
+ }
514
+ check_password_policy_x: {
515
+ const policyName = "digits";
516
+ const policy = passwordPolicies[policyName];
517
+ if (policy === undefined) {
518
+ break check_password_policy_x;
519
+ }
520
+ const minNumberOfDigits = policy;
521
+ if (value.split("").filter(char => !isNaN(parseInt(char))).length >= minNumberOfDigits) {
522
+ break check_password_policy_x;
523
+ }
524
+ const msgArgs = ["invalidPasswordMinDigitsMessage", `${minNumberOfDigits}`];
525
+ errors.push({
526
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
527
+ "errorMessageStr": msgStr(...msgArgs),
528
+ "fieldIndex": undefined,
529
+ "source": {
530
+ "type": "passwordPolicy",
531
+ "name": policyName
532
+ }
533
+ });
534
+ }
535
+ check_password_policy_x: {
536
+ const policyName = "lowerCase";
537
+ const policy = passwordPolicies[policyName];
538
+ if (policy === undefined) {
539
+ break check_password_policy_x;
540
+ }
541
+ const minNumberOfLowerCaseChar = policy;
542
+ if (value.split("").filter(char => char === char.toLowerCase() && char !== char.toUpperCase()).length >= minNumberOfLowerCaseChar) {
543
+ break check_password_policy_x;
544
+ }
545
+ const msgArgs = ["invalidPasswordMinLowerCaseCharsMessage", `${minNumberOfLowerCaseChar}`];
546
+ errors.push({
547
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
548
+ "errorMessageStr": msgStr(...msgArgs),
549
+ "fieldIndex": undefined,
550
+ "source": {
551
+ "type": "passwordPolicy",
552
+ "name": policyName
553
+ }
554
+ });
555
+ }
556
+ check_password_policy_x: {
557
+ const policyName = "upperCase";
558
+ const policy = passwordPolicies[policyName];
559
+ if (policy === undefined) {
560
+ break check_password_policy_x;
561
+ }
562
+ const minNumberOfUpperCaseChar = policy;
563
+ if (value.split("").filter(char => char === char.toUpperCase() && char !== char.toLowerCase()).length >= minNumberOfUpperCaseChar) {
564
+ break check_password_policy_x;
565
+ }
566
+ const msgArgs = ["invalidPasswordMinUpperCaseCharsMessage", `${minNumberOfUpperCaseChar}`];
567
+ errors.push({
568
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
569
+ "errorMessageStr": msgStr(...msgArgs),
570
+ "fieldIndex": undefined,
571
+ "source": {
572
+ "type": "passwordPolicy",
573
+ "name": policyName
574
+ }
575
+ });
576
+ }
577
+ check_password_policy_x: {
578
+ const policyName = "specialChars";
579
+ const policy = passwordPolicies[policyName];
580
+ if (policy === undefined) {
581
+ break check_password_policy_x;
582
+ }
583
+ const minNumberOfSpecialChar = policy;
584
+ if (value.split("").filter(char => !char.match(/[a-zA-Z0-9]/)).length >= minNumberOfSpecialChar) {
585
+ break check_password_policy_x;
586
+ }
587
+ const msgArgs = ["invalidPasswordMinSpecialCharsMessage", `${minNumberOfSpecialChar}`];
588
+ errors.push({
589
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
590
+ "errorMessageStr": msgStr(...msgArgs),
591
+ "fieldIndex": undefined,
592
+ "source": {
593
+ "type": "passwordPolicy",
594
+ "name": policyName
595
+ }
596
+ });
597
+ }
598
+ check_password_policy_x: {
599
+ const policyName = "notUsername";
600
+ const notUsername = passwordPolicies[policyName];
601
+ if (!notUsername) {
602
+ break check_password_policy_x;
603
+ }
604
+ const usernameFormFieldState = formFieldStates.find(formFieldState => formFieldState.attribute.name === "username");
605
+ if (usernameFormFieldState === undefined) {
606
+ break check_password_policy_x;
607
+ }
608
+ const usernameValue = (() => {
609
+ var _a;
610
+ let { valueOrValues } = usernameFormFieldState;
611
+ assert(typeof valueOrValues === "string");
612
+ unFormat_number: {
613
+ const { kcNumberUnFormat } = (_a = attribute.html5DataAnnotations) !== null && _a !== void 0 ? _a : {};
614
+ if (kcNumberUnFormat === undefined) {
615
+ break unFormat_number;
616
+ }
617
+ valueOrValues = formatNumber(valueOrValues, kcNumberUnFormat);
618
+ }
619
+ return valueOrValues;
620
+ })();
621
+ if (value !== usernameValue) {
622
+ break check_password_policy_x;
623
+ }
624
+ const msgArgs = ["invalidPasswordNotUsernameMessage"];
625
+ errors.push({
626
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
627
+ "errorMessageStr": msgStr(...msgArgs),
628
+ "fieldIndex": undefined,
629
+ "source": {
630
+ "type": "passwordPolicy",
631
+ "name": policyName
632
+ }
633
+ });
634
+ }
635
+ check_password_policy_x: {
636
+ const policyName = "notEmail";
637
+ const notEmail = passwordPolicies[policyName];
638
+ if (!notEmail) {
639
+ break check_password_policy_x;
640
+ }
641
+ const emailFormFieldState = formFieldStates.find(formFieldState => formFieldState.attribute.name === "email");
642
+ if (emailFormFieldState === undefined) {
643
+ break check_password_policy_x;
644
+ }
645
+ assert(typeof emailFormFieldState.valueOrValues === "string");
646
+ {
647
+ const emailValue = emailFormFieldState.valueOrValues;
648
+ if (value !== emailValue) {
649
+ break check_password_policy_x;
650
+ }
651
+ }
652
+ const msgArgs = ["invalidPasswordNotEmailMessage"];
653
+ errors.push({
654
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
655
+ "errorMessageStr": msgStr(...msgArgs),
656
+ "fieldIndex": undefined,
657
+ "source": {
658
+ "type": "passwordPolicy",
659
+ "name": policyName
660
+ }
661
+ });
662
+ }
663
+ }
664
+ password_confirm_matches_password: {
665
+ if (attributeName !== "password-confirm") {
666
+ break password_confirm_matches_password;
667
+ }
668
+ const passwordFormFieldState = formFieldStates.find(formFieldState => formFieldState.attribute.name === "password");
669
+ assert(passwordFormFieldState !== undefined);
670
+ assert(typeof passwordFormFieldState.valueOrValues === "string");
671
+ {
672
+ const passwordValue = passwordFormFieldState.valueOrValues;
673
+ if (value === passwordValue) {
674
+ break password_confirm_matches_password;
675
+ }
676
+ }
677
+ const msgArgs = ["invalidPasswordConfirmMessage"];
678
+ errors.push({
679
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
680
+ "errorMessageStr": msgStr(...msgArgs),
681
+ "fieldIndex": undefined,
682
+ "source": {
683
+ "type": "other",
684
+ "rule": "passwordConfirmMatchesPassword"
685
+ }
686
+ });
687
+ }
688
+ const { validators } = attribute;
689
+ required_field: {
690
+ if (!attribute.required) {
691
+ break required_field;
692
+ }
693
+ if (value !== "") {
694
+ break required_field;
695
+ }
696
+ const msgArgs = ["error-user-attribute-required"];
697
+ errors.push({
698
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
699
+ "errorMessageStr": msgStr(...msgArgs),
700
+ "fieldIndex": undefined,
701
+ "source": {
702
+ "type": "other",
703
+ "rule": "requiredField"
704
+ }
705
+ });
706
+ }
707
+ validator_x: {
708
+ const validatorName = "length";
709
+ const validator = validators[validatorName];
710
+ if (validator === undefined) {
711
+ break validator_x;
712
+ }
713
+ const { "ignore.empty.value": ignoreEmptyValue = false, max, min } = validator;
714
+ if (ignoreEmptyValue && value === "") {
715
+ break validator_x;
716
+ }
717
+ const source = {
718
+ "type": "validator",
719
+ "name": validatorName
720
+ };
721
+ if (max !== undefined && value.length > parseInt(`${max}`)) {
722
+ const msgArgs = ["error-invalid-length-too-long", `${max}`];
723
+ errors.push({
724
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
725
+ "errorMessageStr": msgStr(...msgArgs),
726
+ "fieldIndex": undefined,
727
+ source
728
+ });
729
+ }
730
+ if (min !== undefined && value.length < parseInt(`${min}`)) {
731
+ const msgArgs = ["error-invalid-length-too-short", `${min}`];
732
+ errors.push({
733
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
734
+ "errorMessageStr": msgStr(...msgArgs),
735
+ "fieldIndex": undefined,
736
+ source
737
+ });
738
+ }
739
+ }
740
+ validator_x: {
741
+ const validatorName = "pattern";
742
+ const validator = validators[validatorName];
743
+ if (validator === undefined) {
744
+ break validator_x;
745
+ }
746
+ const { "ignore.empty.value": ignoreEmptyValue = false, pattern, "error-message": errorMessageKey } = validator;
747
+ if (ignoreEmptyValue && value === "") {
748
+ break validator_x;
749
+ }
750
+ if (new RegExp(pattern).test(value)) {
751
+ break validator_x;
752
+ }
753
+ const msgArgs = [errorMessageKey !== null && errorMessageKey !== void 0 ? errorMessageKey : id("shouldMatchPattern"), pattern];
754
+ errors.push({
755
+ "errorMessage": _jsx(Fragment, { children: advancedMsg(...msgArgs) }, `${attributeName}-${errors.length}`),
756
+ "errorMessageStr": advancedMsgStr(...msgArgs),
757
+ "fieldIndex": undefined,
758
+ "source": {
759
+ "type": "validator",
760
+ "name": validatorName
761
+ }
762
+ });
763
+ }
764
+ validator_x: {
765
+ {
766
+ const lastError = errors[errors.length - 1];
767
+ if (lastError !== undefined && lastError.source.type === "validator" && lastError.source.name === "pattern") {
768
+ break validator_x;
769
+ }
770
+ }
771
+ const validatorName = "email";
772
+ const validator = validators[validatorName];
773
+ if (validator === undefined) {
774
+ break validator_x;
775
+ }
776
+ const { "ignore.empty.value": ignoreEmptyValue = false } = validator;
777
+ if (ignoreEmptyValue && value === "") {
778
+ break validator_x;
779
+ }
780
+ if (emailRegexp.test(value)) {
781
+ break validator_x;
782
+ }
783
+ const msgArgs = [id("invalidEmailMessage")];
784
+ errors.push({
785
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
786
+ "errorMessageStr": msgStr(...msgArgs),
787
+ "fieldIndex": undefined,
788
+ "source": {
789
+ "type": "validator",
790
+ "name": validatorName
791
+ }
792
+ });
793
+ }
794
+ validator_x: {
795
+ const validatorName = "integer";
796
+ const validator = validators[validatorName];
797
+ if (validator === undefined) {
798
+ break validator_x;
799
+ }
800
+ const { "ignore.empty.value": ignoreEmptyValue = false, max, min } = validator;
801
+ if (ignoreEmptyValue && value === "") {
802
+ break validator_x;
803
+ }
804
+ const intValue = parseInt(value);
805
+ const source = {
806
+ "type": "validator",
807
+ "name": validatorName
808
+ };
809
+ if (isNaN(intValue)) {
810
+ const msgArgs = ["mustBeAnInteger"];
811
+ errors.push({
812
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
813
+ "errorMessageStr": msgStr(...msgArgs),
814
+ "fieldIndex": undefined,
815
+ source
816
+ });
817
+ break validator_x;
818
+ }
819
+ if (max !== undefined && intValue > parseInt(`${max}`)) {
820
+ const msgArgs = ["error-number-out-of-range-too-big", `${max}`];
821
+ errors.push({
822
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
823
+ "errorMessageStr": msgStr(...msgArgs),
824
+ "fieldIndex": undefined,
825
+ source
826
+ });
827
+ break validator_x;
828
+ }
829
+ if (min !== undefined && intValue < parseInt(`${min}`)) {
830
+ const msgArgs = ["error-number-out-of-range-too-small", `${min}`];
831
+ errors.push({
832
+ "errorMessage": _jsx(Fragment, { children: msg(...msgArgs) }, `${attributeName}-${errors.length}`),
833
+ "errorMessageStr": msgStr(...msgArgs),
834
+ "fieldIndex": undefined,
835
+ source
836
+ });
837
+ break validator_x;
838
+ }
839
+ }
840
+ validator_x: {
841
+ const validatorName = "options";
842
+ const validator = validators[validatorName];
843
+ if (validator === undefined) {
844
+ break validator_x;
845
+ }
846
+ if (value === "") {
847
+ break validator_x;
848
+ }
849
+ if (validator.options.indexOf(value) >= 0) {
850
+ break validator_x;
851
+ }
852
+ const msgArgs = [id("notAValidOption")];
853
+ errors.push({
854
+ "errorMessage": _jsx(Fragment, { children: advancedMsg(...msgArgs) }, `${attributeName}-${errors.length}`),
855
+ "errorMessageStr": advancedMsgStr(...msgArgs),
856
+ "fieldIndex": undefined,
857
+ "source": {
858
+ "type": "validator",
859
+ "name": validatorName
860
+ }
861
+ });
862
+ }
863
+ //TODO: Implement missing validators. See Validators type definition.
864
+ return errors;
865
+ });
866
+ return { getErrors };
867
+ }
868
+ //# sourceMappingURL=useUserProfileForm.js.map