@andreyyolkin/keycloakify-vue 0.1.0

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 (349) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +109 -0
  3. package/keycloakify-vue/account/DefaultPage.vue +55 -0
  4. package/keycloakify-vue/account/DefaultPage.vue.d.ts +14 -0
  5. package/keycloakify-vue/account/KcContext/index.d.ts +1 -0
  6. package/keycloakify-vue/account/KcContext/index.js +0 -0
  7. package/keycloakify-vue/account/Template.useInitialize.d.ts +13 -0
  8. package/keycloakify-vue/account/Template.useInitialize.js +20 -0
  9. package/keycloakify-vue/account/Template.vue +178 -0
  10. package/keycloakify-vue/account/Template.vue.d.ts +17 -0
  11. package/keycloakify-vue/account/TemplateProps.d.ts +9 -0
  12. package/keycloakify-vue/account/TemplateProps.js +0 -0
  13. package/keycloakify-vue/account/i18n/i18n.d.ts +11 -0
  14. package/keycloakify-vue/account/i18n/i18n.js +0 -0
  15. package/keycloakify-vue/account/i18n/i18nBuilder.d.ts +18 -0
  16. package/keycloakify-vue/account/i18n/i18nBuilder.js +29 -0
  17. package/keycloakify-vue/account/i18n/index.d.ts +1 -0
  18. package/keycloakify-vue/account/i18n/index.js +1 -0
  19. package/keycloakify-vue/account/i18n/useI18n.d.ts +28 -0
  20. package/keycloakify-vue/account/i18n/useI18n.js +67 -0
  21. package/keycloakify-vue/account/index.d.ts +4 -0
  22. package/keycloakify-vue/account/index.js +8 -0
  23. package/keycloakify-vue/account/pages/Account.vue +182 -0
  24. package/keycloakify-vue/account/pages/Account.vue.d.ts +9 -0
  25. package/keycloakify-vue/account/pages/Applications.vue +192 -0
  26. package/keycloakify-vue/account/pages/Applications.vue.d.ts +9 -0
  27. package/keycloakify-vue/account/pages/FederatedIdentity.vue +123 -0
  28. package/keycloakify-vue/account/pages/FederatedIdentity.vue.d.ts +9 -0
  29. package/keycloakify-vue/account/pages/Log.vue +64 -0
  30. package/keycloakify-vue/account/pages/Log.vue.d.ts +9 -0
  31. package/keycloakify-vue/account/pages/NotImplemented.vue +24 -0
  32. package/keycloakify-vue/account/pages/NotImplemented.vue.d.ts +6 -0
  33. package/keycloakify-vue/account/pages/PageProps.d.ts +9 -0
  34. package/keycloakify-vue/account/pages/PageProps.js +0 -0
  35. package/keycloakify-vue/account/pages/Password.vue +247 -0
  36. package/keycloakify-vue/account/pages/Password.vue.d.ts +9 -0
  37. package/keycloakify-vue/account/pages/Sessions.vue +84 -0
  38. package/keycloakify-vue/account/pages/Sessions.vue.d.ts +9 -0
  39. package/keycloakify-vue/account/pages/Totp.vue +308 -0
  40. package/keycloakify-vue/account/pages/Totp.vue.d.ts +9 -0
  41. package/keycloakify-vue/bin/index.js +14 -0
  42. package/keycloakify-vue/bin/initialize-account-theme/boilerplate/KcContext.js +0 -0
  43. package/keycloakify-vue/bin/initialize-account-theme/boilerplate/KcPage.vue +23 -0
  44. package/keycloakify-vue/bin/initialize-account-theme/boilerplate/KcPageStory.js +18 -0
  45. package/keycloakify-vue/bin/initialize-account-theme/boilerplate/KcPageStory.vue +13 -0
  46. package/keycloakify-vue/bin/initialize-account-theme/boilerplate/i18n.js +5 -0
  47. package/keycloakify-vue/login/DefaultPage.vue +167 -0
  48. package/keycloakify-vue/login/DefaultPage.vue.d.ts +20 -0
  49. package/keycloakify-vue/login/Template.useInitialize.d.ts +18 -0
  50. package/keycloakify-vue/login/Template.useInitialize.js +49 -0
  51. package/keycloakify-vue/login/Template.vue +239 -0
  52. package/keycloakify-vue/login/Template.vue.d.ts +26 -0
  53. package/keycloakify-vue/login/TemplateProps.d.ts +14 -0
  54. package/keycloakify-vue/login/TemplateProps.js +0 -0
  55. package/keycloakify-vue/login/components/AddRemoveButtonsMultiValuedAttribute.vue +59 -0
  56. package/keycloakify-vue/login/components/AddRemoveButtonsMultiValuedAttribute.vue.d.ts +15 -0
  57. package/keycloakify-vue/login/components/FieldErrors.vue +35 -0
  58. package/keycloakify-vue/login/components/FieldErrors.vue.d.ts +14 -0
  59. package/keycloakify-vue/login/components/GroupLabel.vue +68 -0
  60. package/keycloakify-vue/login/components/GroupLabel.vue.d.ts +14 -0
  61. package/keycloakify-vue/login/components/InputFieldByType.vue +94 -0
  62. package/keycloakify-vue/login/components/InputFieldByType.vue.d.ts +4 -0
  63. package/keycloakify-vue/login/components/InputFieldByTypeProps.d.ts +12 -0
  64. package/keycloakify-vue/login/components/InputFieldByTypeProps.js +0 -0
  65. package/keycloakify-vue/login/components/InputTag.vue +105 -0
  66. package/keycloakify-vue/login/components/InputTag.vue.d.ts +7 -0
  67. package/keycloakify-vue/login/components/InputTagSelects.vue +108 -0
  68. package/keycloakify-vue/login/components/InputTagSelects.vue.d.ts +4 -0
  69. package/keycloakify-vue/login/components/LogoutOtherSessions.vue +27 -0
  70. package/keycloakify-vue/login/components/LogoutOtherSessions.vue.d.ts +9 -0
  71. package/keycloakify-vue/login/components/PasswordWrapper.vue +42 -0
  72. package/keycloakify-vue/login/components/PasswordWrapper.vue.d.ts +20 -0
  73. package/keycloakify-vue/login/components/SelectTag.vue +74 -0
  74. package/keycloakify-vue/login/components/SelectTag.vue.d.ts +4 -0
  75. package/keycloakify-vue/login/components/TermsAcceptance.vue +59 -0
  76. package/keycloakify-vue/login/components/TermsAcceptance.vue.d.ts +13 -0
  77. package/keycloakify-vue/login/components/TextareaTag.vue +47 -0
  78. package/keycloakify-vue/login/components/TextareaTag.vue.d.ts +4 -0
  79. package/keycloakify-vue/login/components/UserProfileFormFields.vue +119 -0
  80. package/keycloakify-vue/login/components/UserProfileFormFields.vue.d.ts +33 -0
  81. package/keycloakify-vue/login/components/UserProfileFormFieldsProps.d.ts +22 -0
  82. package/keycloakify-vue/login/components/UserProfileFormFieldsProps.js +0 -0
  83. package/keycloakify-vue/login/components/inputLabel.d.ts +4 -0
  84. package/keycloakify-vue/login/components/inputLabel.js +15 -0
  85. package/keycloakify-vue/login/i18n/i18n.d.ts +11 -0
  86. package/keycloakify-vue/login/i18n/i18n.js +0 -0
  87. package/keycloakify-vue/login/i18n/i18nBuilder.d.ts +18 -0
  88. package/keycloakify-vue/login/i18n/i18nBuilder.js +29 -0
  89. package/keycloakify-vue/login/i18n/index.d.ts +1 -0
  90. package/keycloakify-vue/login/i18n/index.js +1 -0
  91. package/keycloakify-vue/login/i18n/useI18n.d.ts +28 -0
  92. package/keycloakify-vue/login/i18n/useI18n.js +67 -0
  93. package/keycloakify-vue/login/index.d.ts +5 -0
  94. package/keycloakify-vue/login/index.js +10 -0
  95. package/keycloakify-vue/login/lib/useUserProfileForm.d.ts +53 -0
  96. package/keycloakify-vue/login/lib/useUserProfileForm.js +50 -0
  97. package/keycloakify-vue/login/pages/Code.vue +54 -0
  98. package/keycloakify-vue/login/pages/Code.vue.d.ts +9 -0
  99. package/keycloakify-vue/login/pages/DeleteAccountConfirm.vue +69 -0
  100. package/keycloakify-vue/login/pages/DeleteAccountConfirm.vue.d.ts +9 -0
  101. package/keycloakify-vue/login/pages/DeleteCredential.vue +56 -0
  102. package/keycloakify-vue/login/pages/DeleteCredential.vue.d.ts +9 -0
  103. package/keycloakify-vue/login/pages/Error.vue +41 -0
  104. package/keycloakify-vue/login/pages/Error.vue.d.ts +9 -0
  105. package/keycloakify-vue/login/pages/FrontchannelLogout.vue +67 -0
  106. package/keycloakify-vue/login/pages/FrontchannelLogout.vue.d.ts +9 -0
  107. package/keycloakify-vue/login/pages/IdpReviewUserProfile.vue +77 -0
  108. package/keycloakify-vue/login/pages/IdpReviewUserProfile.vue.d.ts +14 -0
  109. package/keycloakify-vue/login/pages/Info.vue +61 -0
  110. package/keycloakify-vue/login/pages/Info.vue.d.ts +9 -0
  111. package/keycloakify-vue/login/pages/LinkIdpAction.vue +66 -0
  112. package/keycloakify-vue/login/pages/LinkIdpAction.vue.d.ts +9 -0
  113. package/keycloakify-vue/login/pages/Login.vue +230 -0
  114. package/keycloakify-vue/login/pages/Login.vue.d.ts +9 -0
  115. package/keycloakify-vue/login/pages/LoginConfigTotp.vue +233 -0
  116. package/keycloakify-vue/login/pages/LoginConfigTotp.vue.d.ts +9 -0
  117. package/keycloakify-vue/login/pages/LoginIdpLinkConfirm.vue +57 -0
  118. package/keycloakify-vue/login/pages/LoginIdpLinkConfirm.vue.d.ts +9 -0
  119. package/keycloakify-vue/login/pages/LoginIdpLinkConfirmOverride.vue +56 -0
  120. package/keycloakify-vue/login/pages/LoginIdpLinkConfirmOverride.vue.d.ts +9 -0
  121. package/keycloakify-vue/login/pages/LoginIdpLinkEmail.vue +52 -0
  122. package/keycloakify-vue/login/pages/LoginIdpLinkEmail.vue.d.ts +9 -0
  123. package/keycloakify-vue/login/pages/LoginOauth2DeviceVerifyUserCode.vue +82 -0
  124. package/keycloakify-vue/login/pages/LoginOauth2DeviceVerifyUserCode.vue.d.ts +9 -0
  125. package/keycloakify-vue/login/pages/LoginOauthGrant.vue +131 -0
  126. package/keycloakify-vue/login/pages/LoginOauthGrant.vue.d.ts +9 -0
  127. package/keycloakify-vue/login/pages/LoginOtp.vue +135 -0
  128. package/keycloakify-vue/login/pages/LoginOtp.vue.d.ts +9 -0
  129. package/keycloakify-vue/login/pages/LoginPageExpired.vue +44 -0
  130. package/keycloakify-vue/login/pages/LoginPageExpired.vue.d.ts +9 -0
  131. package/keycloakify-vue/login/pages/LoginPasskeysConditionalAuthenticate.useScript.d.ts +21 -0
  132. package/keycloakify-vue/login/pages/LoginPasskeysConditionalAuthenticate.useScript.js +74 -0
  133. package/keycloakify-vue/login/pages/LoginPasskeysConditionalAuthenticate.vue +255 -0
  134. package/keycloakify-vue/login/pages/LoginPasskeysConditionalAuthenticate.vue.d.ts +9 -0
  135. package/keycloakify-vue/login/pages/LoginPassword.useScript.d.ts +23 -0
  136. package/keycloakify-vue/login/pages/LoginPassword.useScript.js +64 -0
  137. package/keycloakify-vue/login/pages/LoginPassword.vue +191 -0
  138. package/keycloakify-vue/login/pages/LoginPassword.vue.d.ts +9 -0
  139. package/keycloakify-vue/login/pages/LoginRecoveryAuthnCodeConfig.useScript.d.ts +9 -0
  140. package/keycloakify-vue/login/pages/LoginRecoveryAuthnCodeConfig.useScript.js +139 -0
  141. package/keycloakify-vue/login/pages/LoginRecoveryAuthnCodeConfig.vue +183 -0
  142. package/keycloakify-vue/login/pages/LoginRecoveryAuthnCodeConfig.vue.d.ts +9 -0
  143. package/keycloakify-vue/login/pages/LoginRecoveryAuthnCodeInput.vue +90 -0
  144. package/keycloakify-vue/login/pages/LoginRecoveryAuthnCodeInput.vue.d.ts +9 -0
  145. package/keycloakify-vue/login/pages/LoginResetOtp.vue +88 -0
  146. package/keycloakify-vue/login/pages/LoginResetOtp.vue.d.ts +9 -0
  147. package/keycloakify-vue/login/pages/LoginResetPassword.vue +114 -0
  148. package/keycloakify-vue/login/pages/LoginResetPassword.vue.d.ts +9 -0
  149. package/keycloakify-vue/login/pages/LoginUpdatePassword.vue +145 -0
  150. package/keycloakify-vue/login/pages/LoginUpdatePassword.vue.d.ts +9 -0
  151. package/keycloakify-vue/login/pages/LoginUpdateProfile.vue +94 -0
  152. package/keycloakify-vue/login/pages/LoginUpdateProfile.vue.d.ts +14 -0
  153. package/keycloakify-vue/login/pages/LoginUsername.useScript.d.ts +23 -0
  154. package/keycloakify-vue/login/pages/LoginUsername.useScript.js +64 -0
  155. package/keycloakify-vue/login/pages/LoginUsername.vue +263 -0
  156. package/keycloakify-vue/login/pages/LoginUsername.vue.d.ts +9 -0
  157. package/keycloakify-vue/login/pages/LoginVerifyEmail.vue +39 -0
  158. package/keycloakify-vue/login/pages/LoginVerifyEmail.vue.d.ts +9 -0
  159. package/keycloakify-vue/login/pages/LoginX509Info.vue +120 -0
  160. package/keycloakify-vue/login/pages/LoginX509Info.vue.d.ts +9 -0
  161. package/keycloakify-vue/login/pages/LogoutConfirm.vue +73 -0
  162. package/keycloakify-vue/login/pages/LogoutConfirm.vue.d.ts +9 -0
  163. package/keycloakify-vue/login/pages/NotImplemented.vue +12 -0
  164. package/keycloakify-vue/login/pages/NotImplemented.vue.d.ts +6 -0
  165. package/keycloakify-vue/login/pages/PageProps.d.ts +9 -0
  166. package/keycloakify-vue/login/pages/PageProps.js +0 -0
  167. package/keycloakify-vue/login/pages/Register.vue +158 -0
  168. package/keycloakify-vue/login/pages/Register.vue.d.ts +14 -0
  169. package/keycloakify-vue/login/pages/SamlPostForm.vue +75 -0
  170. package/keycloakify-vue/login/pages/SamlPostForm.vue.d.ts +9 -0
  171. package/keycloakify-vue/login/pages/SelectAuthenticator.vue +65 -0
  172. package/keycloakify-vue/login/pages/SelectAuthenticator.vue.d.ts +9 -0
  173. package/keycloakify-vue/login/pages/SelectOrganization.vue +89 -0
  174. package/keycloakify-vue/login/pages/SelectOrganization.vue.d.ts +9 -0
  175. package/keycloakify-vue/login/pages/Terms.vue +56 -0
  176. package/keycloakify-vue/login/pages/Terms.vue.d.ts +9 -0
  177. package/keycloakify-vue/login/pages/UpdateEmail.vue +100 -0
  178. package/keycloakify-vue/login/pages/UpdateEmail.vue.d.ts +14 -0
  179. package/keycloakify-vue/login/pages/WebauthnAuthenticate.useScript.d.ts +22 -0
  180. package/keycloakify-vue/login/pages/WebauthnAuthenticate.useScript.js +53 -0
  181. package/keycloakify-vue/login/pages/WebauthnAuthenticate.vue +186 -0
  182. package/keycloakify-vue/login/pages/WebauthnAuthenticate.vue.d.ts +9 -0
  183. package/keycloakify-vue/login/pages/WebauthnError.vue +84 -0
  184. package/keycloakify-vue/login/pages/WebauthnError.vue.d.ts +9 -0
  185. package/keycloakify-vue/login/pages/WebauthnRegister.useScript.d.ts +28 -0
  186. package/keycloakify-vue/login/pages/WebauthnRegister.useScript.js +75 -0
  187. package/keycloakify-vue/login/pages/WebauthnRegister.vue +105 -0
  188. package/keycloakify-vue/login/pages/WebauthnRegister.vue.d.ts +9 -0
  189. package/keycloakify-vue/tools/useInsertLinkTags.d.ts +12 -0
  190. package/keycloakify-vue/tools/useInsertLinkTags.js +47 -0
  191. package/keycloakify-vue/tools/useInsertScriptTags.d.ts +19 -0
  192. package/keycloakify-vue/tools/useInsertScriptTags.js +56 -0
  193. package/keycloakify-vue/tools/useSetClassName.d.ts +4 -0
  194. package/keycloakify-vue/tools/useSetClassName.js +16 -0
  195. package/package.json +553 -0
  196. package/src/account/DefaultPage.vue +55 -0
  197. package/src/account/KcContext/index.ts +1 -0
  198. package/src/account/Template.useInitialize.ts +34 -0
  199. package/src/account/Template.vue +178 -0
  200. package/src/account/TemplateProps.ts +11 -0
  201. package/src/account/i18n/i18n.ts +16 -0
  202. package/src/account/i18n/i18nBuilder.ts +100 -0
  203. package/src/account/i18n/index.ts +1 -0
  204. package/src/account/i18n/useI18n.ts +128 -0
  205. package/src/account/index.ts +4 -0
  206. package/src/account/pages/Account.vue +182 -0
  207. package/src/account/pages/Applications.vue +192 -0
  208. package/src/account/pages/FederatedIdentity.vue +123 -0
  209. package/src/account/pages/Log.vue +64 -0
  210. package/src/account/pages/NotImplemented.vue +24 -0
  211. package/src/account/pages/PageProps.ts +10 -0
  212. package/src/account/pages/Password.vue +247 -0
  213. package/src/account/pages/Sessions.vue +84 -0
  214. package/src/account/pages/Totp.vue +308 -0
  215. package/src/bin/initialize-account-theme/boilerplate/KcContext.ts +11 -0
  216. package/src/bin/initialize-account-theme/boilerplate/KcPage.vue +23 -0
  217. package/src/bin/initialize-account-theme/boilerplate/KcPageStory.ts +22 -0
  218. package/src/bin/initialize-account-theme/boilerplate/KcPageStory.vue +13 -0
  219. package/src/bin/initialize-account-theme/boilerplate/i18n.ts +8 -0
  220. package/src/login/DefaultPage.vue +167 -0
  221. package/src/login/Template.useInitialize.ts +71 -0
  222. package/src/login/Template.vue +239 -0
  223. package/src/login/TemplateProps.ts +17 -0
  224. package/src/login/components/AddRemoveButtonsMultiValuedAttribute.vue +59 -0
  225. package/src/login/components/FieldErrors.vue +35 -0
  226. package/src/login/components/GroupLabel.vue +68 -0
  227. package/src/login/components/InputFieldByType.vue +94 -0
  228. package/src/login/components/InputFieldByTypeProps.ts +13 -0
  229. package/src/login/components/InputTag.vue +105 -0
  230. package/src/login/components/InputTagSelects.vue +108 -0
  231. package/src/login/components/LogoutOtherSessions.vue +27 -0
  232. package/src/login/components/PasswordWrapper.vue +42 -0
  233. package/src/login/components/SelectTag.vue +74 -0
  234. package/src/login/components/TermsAcceptance.vue +59 -0
  235. package/src/login/components/TextareaTag.vue +47 -0
  236. package/src/login/components/UserProfileFormFields.vue +119 -0
  237. package/src/login/components/UserProfileFormFieldsProps.ts +22 -0
  238. package/src/login/components/inputLabel.ts +18 -0
  239. package/src/login/i18n/i18n.ts +16 -0
  240. package/src/login/i18n/i18nBuilder.ts +100 -0
  241. package/src/login/i18n/index.ts +1 -0
  242. package/src/login/i18n/useI18n.ts +128 -0
  243. package/src/login/index.ts +5 -0
  244. package/src/login/lib/useUserProfileForm.ts +121 -0
  245. package/src/login/pages/Code.vue +54 -0
  246. package/src/login/pages/DeleteAccountConfirm.vue +69 -0
  247. package/src/login/pages/DeleteCredential.vue +56 -0
  248. package/src/login/pages/Error.vue +41 -0
  249. package/src/login/pages/FrontchannelLogout.vue +67 -0
  250. package/src/login/pages/IdpReviewUserProfile.vue +77 -0
  251. package/src/login/pages/Info.vue +61 -0
  252. package/src/login/pages/LinkIdpAction.vue +66 -0
  253. package/src/login/pages/Login.vue +230 -0
  254. package/src/login/pages/LoginConfigTotp.vue +233 -0
  255. package/src/login/pages/LoginIdpLinkConfirm.vue +57 -0
  256. package/src/login/pages/LoginIdpLinkConfirmOverride.vue +56 -0
  257. package/src/login/pages/LoginIdpLinkEmail.vue +52 -0
  258. package/src/login/pages/LoginOauth2DeviceVerifyUserCode.vue +82 -0
  259. package/src/login/pages/LoginOauthGrant.vue +131 -0
  260. package/src/login/pages/LoginOtp.vue +135 -0
  261. package/src/login/pages/LoginPageExpired.vue +44 -0
  262. package/src/login/pages/LoginPasskeysConditionalAuthenticate.useScript.ts +96 -0
  263. package/src/login/pages/LoginPasskeysConditionalAuthenticate.vue +255 -0
  264. package/src/login/pages/LoginPassword.useScript.ts +88 -0
  265. package/src/login/pages/LoginPassword.vue +191 -0
  266. package/src/login/pages/LoginRecoveryAuthnCodeConfig.useScript.ts +152 -0
  267. package/src/login/pages/LoginRecoveryAuthnCodeConfig.vue +183 -0
  268. package/src/login/pages/LoginRecoveryAuthnCodeInput.vue +90 -0
  269. package/src/login/pages/LoginResetOtp.vue +88 -0
  270. package/src/login/pages/LoginResetPassword.vue +114 -0
  271. package/src/login/pages/LoginUpdatePassword.vue +145 -0
  272. package/src/login/pages/LoginUpdateProfile.vue +94 -0
  273. package/src/login/pages/LoginUsername.useScript.ts +88 -0
  274. package/src/login/pages/LoginUsername.vue +263 -0
  275. package/src/login/pages/LoginVerifyEmail.vue +39 -0
  276. package/src/login/pages/LoginX509Info.vue +120 -0
  277. package/src/login/pages/LogoutConfirm.vue +73 -0
  278. package/src/login/pages/NotImplemented.vue +12 -0
  279. package/src/login/pages/PageProps.ts +10 -0
  280. package/src/login/pages/Register.vue +158 -0
  281. package/src/login/pages/SamlPostForm.vue +75 -0
  282. package/src/login/pages/SelectAuthenticator.vue +65 -0
  283. package/src/login/pages/SelectOrganization.vue +89 -0
  284. package/src/login/pages/Terms.vue +56 -0
  285. package/src/login/pages/UpdateEmail.vue +100 -0
  286. package/src/login/pages/WebauthnAuthenticate.useScript.ts +75 -0
  287. package/src/login/pages/WebauthnAuthenticate.vue +186 -0
  288. package/src/login/pages/WebauthnError.vue +84 -0
  289. package/src/login/pages/WebauthnRegister.useScript.ts +109 -0
  290. package/src/login/pages/WebauthnRegister.vue +105 -0
  291. package/src/tools/useInsertLinkTags.ts +62 -0
  292. package/src/tools/useInsertScriptTags.ts +75 -0
  293. package/src/tools/useSetClassName.ts +15 -0
  294. package/stories/account/KcContext.ts +13 -0
  295. package/stories/account/KcContextMock.ts +26 -0
  296. package/stories/account/KcPage.vue +26 -0
  297. package/stories/account/KcPageStory.vue +13 -0
  298. package/stories/account/i18n.ts +7 -0
  299. package/stories/account/pages/Account.stories.ts +22 -0
  300. package/stories/account/pages/Applications.stories.ts +70 -0
  301. package/stories/account/pages/FederatedIdentity.stories.ts +64 -0
  302. package/stories/account/pages/Log.stories.ts +42 -0
  303. package/stories/account/pages/Password.stories.ts +22 -0
  304. package/stories/account/pages/Sessions.stories.ts +41 -0
  305. package/stories/account/pages/Totp.stories.ts +33 -0
  306. package/stories/kc.gen.ts +17 -0
  307. package/stories/login/KcContext.ts +13 -0
  308. package/stories/login/KcContextMock.ts +26 -0
  309. package/stories/login/KcPage.vue +28 -0
  310. package/stories/login/KcPageStory.vue +13 -0
  311. package/stories/login/i18n.ts +7 -0
  312. package/stories/login/pages/Code.stories.ts +50 -0
  313. package/stories/login/pages/DeleteAccountConfirm.stories.ts +32 -0
  314. package/stories/login/pages/DeleteCredential.stories.ts +23 -0
  315. package/stories/login/pages/Error.stories.ts +53 -0
  316. package/stories/login/pages/FrontchannelLogout.stories.ts +24 -0
  317. package/stories/login/pages/IdpReviewUserProfile.stories.ts +56 -0
  318. package/stories/login/pages/Info.stories.ts +52 -0
  319. package/stories/login/pages/LinkIdpAction.stories.ts +30 -0
  320. package/stories/login/pages/Login.stories.ts +76 -0
  321. package/stories/login/pages/LoginConfigTotp.stories.ts +53 -0
  322. package/stories/login/pages/LoginIdpLinkConfirm.stories.ts +34 -0
  323. package/stories/login/pages/LoginIdpLinkConfirmOverride.stories.ts +14 -0
  324. package/stories/login/pages/LoginIdpLinkEmail.stories.ts +60 -0
  325. package/stories/login/pages/LoginOauth2DeviceVerifyUserCode.stories.ts +42 -0
  326. package/stories/login/pages/LoginOauthGrant.stories.ts +95 -0
  327. package/stories/login/pages/LoginOtp.stories.ts +92 -0
  328. package/stories/login/pages/LoginPageExpired.stories.ts +29 -0
  329. package/stories/login/pages/LoginPasskeysConditionalAuthenticate.stories.ts +14 -0
  330. package/stories/login/pages/LoginPassword.stories.ts +49 -0
  331. package/stories/login/pages/LoginRecoveryAuthnCodeConfig.stories.ts +28 -0
  332. package/stories/login/pages/LoginRecoveryAuthnCodeInput.stories.ts +14 -0
  333. package/stories/login/pages/LoginResetOtp.stories.ts +69 -0
  334. package/stories/login/pages/LoginResetPassword.stories.ts +48 -0
  335. package/stories/login/pages/LoginUpdatePassword.stories.ts +52 -0
  336. package/stories/login/pages/LoginUpdateProfile.stories.ts +29 -0
  337. package/stories/login/pages/LoginUsername.stories.ts +25 -0
  338. package/stories/login/pages/LoginVerifyEmail.stories.ts +63 -0
  339. package/stories/login/pages/LoginX509Info.stories.ts +29 -0
  340. package/stories/login/pages/LogoutConfirm.stories.ts +35 -0
  341. package/stories/login/pages/Register.stories.ts +76 -0
  342. package/stories/login/pages/SamlPostForm.stories.ts +14 -0
  343. package/stories/login/pages/SelectAuthenticator.stories.ts +89 -0
  344. package/stories/login/pages/SelectOrganization.stories.ts +63 -0
  345. package/stories/login/pages/Terms.stories.ts +78 -0
  346. package/stories/login/pages/UpdateEmail.stories.ts +28 -0
  347. package/stories/login/pages/WebauthnAuthenticate.stories.ts +147 -0
  348. package/stories/login/pages/WebauthnError.stories.ts +77 -0
  349. package/stories/login/pages/WebauthnRegister.stories.ts +54 -0
@@ -0,0 +1,186 @@
1
+ <script setup lang="ts">
2
+ import type { KcContext } from 'keycloakify/login/KcContext';
3
+ import { getKcClsx, type ClassKey } from 'keycloakify/login/lib/kcClsx';
4
+ import { clsx } from 'keycloakify/tools/clsx';
5
+ import type { CxArg } from 'keycloakify/tools/clsx_withTransform';
6
+ import { toRef } from 'vue';
7
+ import type { I18n } from '../i18n/i18n';
8
+ import type { PageProps } from './PageProps';
9
+ import { useScript } from './WebauthnAuthenticate.useScript';
10
+
11
+ const props = defineProps<PageProps<Extract<KcContext, { pageId: 'webauthn-authenticate.ftl' }>, I18n>>();
12
+
13
+ const { kcClsx } = getKcClsx({
14
+ doUseDefaultCss: props.doUseDefaultCss,
15
+ classes: props.classes,
16
+ });
17
+
18
+ const kcContext = props.kcContext;
19
+ const { url, realm, registrationDisabled, authenticators, shouldDisplayAuthenticators } = kcContext;
20
+
21
+ const authButtonId = 'authenticateWebAuthnButton';
22
+
23
+ useScript({ authButtonId, kcContext, i18n: toRef(props, 'i18n') });
24
+ </script>
25
+
26
+ <template>
27
+ <component
28
+ :is="Template"
29
+ :kcContext="kcContext"
30
+ :i18n="props.i18n"
31
+ :doUseDefaultCss="doUseDefaultCss"
32
+ :classes="classes"
33
+ :displayInfo="realm.registrationAllowed && !registrationDisabled"
34
+ >
35
+ <template #header>
36
+ <component :is="props.i18n.msg('webauthn-login-title')" />
37
+ </template>
38
+
39
+ <template #info>
40
+ <div id="kc-registration">
41
+ <span>
42
+ <component :is="props.i18n.msg('noAccount')" />&nbsp;
43
+ <a
44
+ :tabindex="6"
45
+ :href="url.registrationUrl"
46
+ >
47
+ <component :is="props.i18n.msg('doRegister')" />
48
+ </a>
49
+ </span>
50
+ </div>
51
+ </template>
52
+
53
+ <div
54
+ id="kc-form-webauthn"
55
+ :class="kcClsx('kcFormClass')"
56
+ >
57
+ <form
58
+ id="webauth"
59
+ :action="url.loginAction"
60
+ method="post"
61
+ >
62
+ <input
63
+ type="hidden"
64
+ id="clientDataJSON"
65
+ name="clientDataJSON"
66
+ />
67
+ <input
68
+ type="hidden"
69
+ id="authenticatorData"
70
+ name="authenticatorData"
71
+ />
72
+ <input
73
+ type="hidden"
74
+ id="signature"
75
+ name="signature"
76
+ />
77
+ <input
78
+ type="hidden"
79
+ id="credentialId"
80
+ name="credentialId"
81
+ />
82
+ <input
83
+ type="hidden"
84
+ id="userHandle"
85
+ name="userHandle"
86
+ />
87
+ <input
88
+ type="hidden"
89
+ id="error"
90
+ name="error"
91
+ />
92
+ </form>
93
+ <div :class="clsx(kcClsx('kcFormGroupClass'), 'no-bottom-margin')">
94
+ <template v-if="authenticators">
95
+ <form
96
+ id="authn_select"
97
+ :class="kcClsx('kcFormClass')"
98
+ >
99
+ <input
100
+ v-for="authenticator in authenticators.authenticators"
101
+ :key="authenticator.credentialId"
102
+ type="hidden"
103
+ name="authn_use_chk"
104
+ :value="authenticator.credentialId"
105
+ />
106
+ </form>
107
+
108
+ <template v-if="shouldDisplayAuthenticators">
109
+ <p
110
+ v-if="authenticators.authenticators.length > 1"
111
+ :class="kcClsx('kcSelectAuthListItemTitle')"
112
+ >
113
+ <component :is="props.i18n.msg('webauthn-available-authenticators')" />
114
+ </p>
115
+ <div :class="kcClsx('kcFormOptionsClass')">
116
+ <div
117
+ v-for="(authenticator, idx) in authenticators.authenticators"
118
+ :key="authenticator.credentialId"
119
+ :id="`kc-webauthn-authenticator-item-${idx}`"
120
+ :class="kcClsx('kcSelectAuthListItemClass')"
121
+ >
122
+ <div :class="kcClsx('kcSelectAuthListItemIconClass')">
123
+ <i
124
+ :class="
125
+ clsx(
126
+ (() => {
127
+ const klass = kcClsx(authenticator.transports.iconClass as CxArg<ClassKey>);
128
+ if (klass === authenticator.transports.iconClass) {
129
+ return kcClsx('kcWebAuthnDefaultIcon');
130
+ }
131
+ return klass;
132
+ })(),
133
+ kcClsx('kcSelectAuthListItemIconPropertyClass'),
134
+ )
135
+ "
136
+ ></i>
137
+ </div>
138
+ <div :class="kcClsx('kcSelectAuthListItemArrowIconClass')">
139
+ <div
140
+ :id="`kc-webauthn-authenticator-label-${idx}`"
141
+ :class="kcClsx('kcSelectAuthListItemHeadingClass')"
142
+ >
143
+ <component :is="props.i18n.advancedMsg(authenticator.label)" />
144
+ </div>
145
+ <div
146
+ v-if="authenticator.transports.displayNameProperties?.length"
147
+ :id="`kc-webauthn-authenticator-transport-${idx}`"
148
+ :class="kcClsx('kcSelectAuthListItemDescriptionClass')"
149
+ >
150
+ <template
151
+ v-for="(displayNameProperty, dpIdx) in authenticator.transports.displayNameProperties"
152
+ :key="displayNameProperty"
153
+ >
154
+ <component :is="props.i18n.advancedMsg(displayNameProperty)" />
155
+ <span v-if="dpIdx !== authenticator.transports.displayNameProperties!.length - 1">, </span>
156
+ </template>
157
+ </div>
158
+ <div :class="kcClsx('kcSelectAuthListItemDescriptionClass')">
159
+ <span :id="`kc-webauthn-authenticator-createdlabel-${idx}`">
160
+ <component :is="props.i18n.msg('webauthn-createdAt-label')" />
161
+ </span>
162
+ <span :id="`kc-webauthn-authenticator-created-${idx}`">{{ authenticator.createdAt }}</span>
163
+ </div>
164
+ <div :class="kcClsx('kcSelectAuthListItemFillClass')"></div>
165
+ </div>
166
+ </div>
167
+ </div>
168
+ </template>
169
+ </template>
170
+
171
+ <div
172
+ id="kc-form-buttons"
173
+ :class="kcClsx('kcFormButtonsClass')"
174
+ >
175
+ <input
176
+ :id="authButtonId"
177
+ type="button"
178
+ autofocus
179
+ :value="props.i18n.msgStr('webauthn-doAuthenticate')"
180
+ :class="kcClsx('kcButtonClass', 'kcButtonPrimaryClass', 'kcButtonBlockClass', 'kcButtonLargeClass')"
181
+ />
182
+ </div>
183
+ </div>
184
+ </div>
185
+ </component>
186
+ </template>
@@ -0,0 +1,84 @@
1
+ <script setup lang="ts">
2
+ import type { KcContext } from 'keycloakify/login/KcContext';
3
+ import { getKcClsx } from 'keycloakify/login/lib/kcClsx';
4
+ import type { I18n } from '../i18n/i18n';
5
+ import type { PageProps } from './PageProps';
6
+
7
+ const props = defineProps<PageProps<Extract<KcContext, { pageId: 'webauthn-error.ftl' }>, I18n>>();
8
+
9
+ const { kcClsx } = getKcClsx({
10
+ doUseDefaultCss: props.doUseDefaultCss,
11
+ classes: props.classes,
12
+ });
13
+
14
+ const kcContext = props.kcContext;
15
+ const { url, isAppInitiatedAction, execution } = kcContext;
16
+ </script>
17
+
18
+ <template>
19
+ <component
20
+ :is="Template"
21
+ :kcContext="kcContext"
22
+ :i18n="i18n"
23
+ :doUseDefaultCss="doUseDefaultCss"
24
+ :classes="classes"
25
+ :displayMessage="true"
26
+ >
27
+ <template #header>
28
+ <component :is="i18n.msg('webauthn-error-title')" />
29
+ </template>
30
+
31
+ <form
32
+ id="kc-error-credential-form"
33
+ :class="kcClsx('kcFormClass')"
34
+ :action="url.loginAction"
35
+ method="post"
36
+ >
37
+ <input
38
+ type="hidden"
39
+ id="executionValue"
40
+ name="authenticationExecution"
41
+ />
42
+ <input
43
+ type="hidden"
44
+ id="isSetRetry"
45
+ name="isSetRetry"
46
+ />
47
+ </form>
48
+ <input
49
+ :tabindex="4"
50
+ @click="
51
+ () => {
52
+ // @ts-expect-error: Trusted Keycloak's code
53
+ document.getElementById('isSetRetry').value = 'retry';
54
+ // @ts-expect-error: Trusted Keycloak's code
55
+ document.getElementById('executionValue').value = execution;
56
+ // @ts-expect-error: Trusted Keycloak's code
57
+ document.getElementById('kc-error-credential-form').requestSubmit();
58
+ }
59
+ "
60
+ type="button"
61
+ :class="kcClsx('kcButtonClass', 'kcButtonPrimaryClass', 'kcButtonBlockClass', 'kcButtonLargeClass')"
62
+ name="try-again"
63
+ id="kc-try-again"
64
+ :value="i18n.msgStr('doTryAgain')"
65
+ />
66
+ <form
67
+ v-if="isAppInitiatedAction"
68
+ :action="url.loginAction"
69
+ :class="kcClsx('kcFormClass')"
70
+ id="kc-webauthn-settings-form"
71
+ method="post"
72
+ >
73
+ <button
74
+ type="submit"
75
+ :class="kcClsx('kcButtonClass', 'kcButtonDefaultClass', 'kcButtonBlockClass', 'kcButtonLargeClass')"
76
+ id="cancelWebAuthnAIA"
77
+ name="cancel-aia"
78
+ value="true"
79
+ >
80
+ {{ i18n.msgStr('doCancel') }}
81
+ </button>
82
+ </form>
83
+ </component>
84
+ </template>
@@ -0,0 +1,109 @@
1
+ import { onMounted, watch, type Ref } from 'vue';
2
+ import { useInsertScriptTags } from '../../tools/useInsertScriptTags';
3
+ import { assert } from 'keycloakify/tools/assert';
4
+ import { waitForElementMountedOnDom } from 'keycloakify/tools/waitForElementMountedOnDom';
5
+ import type { KcContext } from 'keycloakify/login/KcContext';
6
+
7
+ type KcContextLike = {
8
+ url: {
9
+ resourcesPath: string;
10
+ };
11
+ challenge: string;
12
+ userid: string;
13
+ username: string;
14
+ signatureAlgorithms: string[];
15
+ rpEntityName: string;
16
+ rpId: string;
17
+ attestationConveyancePreference: string;
18
+ authenticatorAttachment: string;
19
+ requireResidentKey: string;
20
+ userVerificationRequirement: string;
21
+ createTimeout: number | string;
22
+ excludeCredentialIds: string;
23
+ };
24
+
25
+ assert<keyof KcContextLike extends keyof KcContext.WebauthnRegister ? true : false>();
26
+ assert<KcContext.WebauthnRegister extends KcContextLike ? true : false>();
27
+
28
+ type I18nLike = {
29
+ msgStr: (
30
+ key:
31
+ | 'webauthn-registration-init-label'
32
+ | 'webauthn-registration-init-label-prompt'
33
+ | 'webauthn-unsupported-browser-text',
34
+ ) => string;
35
+ isFetchingTranslations: boolean;
36
+ };
37
+
38
+ export function useScript(params: { authButtonId: string; kcContext: KcContextLike; i18n: Ref<I18nLike> }) {
39
+ const { authButtonId, kcContext, i18n } = params;
40
+
41
+ const {
42
+ url,
43
+ challenge,
44
+ userid,
45
+ username,
46
+ signatureAlgorithms,
47
+ rpEntityName,
48
+ rpId,
49
+ attestationConveyancePreference,
50
+ authenticatorAttachment,
51
+ requireResidentKey,
52
+ userVerificationRequirement,
53
+ createTimeout,
54
+ excludeCredentialIds,
55
+ } = kcContext;
56
+
57
+ const { insertScriptTags } = useInsertScriptTags({
58
+ componentOrHookName: 'WebauthnRegister',
59
+ scriptTags: [
60
+ {
61
+ type: 'module',
62
+ textContent: () => `
63
+ import { registerByWebAuthn } from "${url.resourcesPath}/js/webauthnRegister.js";
64
+ const registerButton = document.getElementById('${authButtonId}');
65
+ registerButton.addEventListener("click", function() {
66
+ const input = {
67
+ challenge : '${challenge}',
68
+ userid : '${userid}',
69
+ username : '${username}',
70
+ signatureAlgorithms : ${JSON.stringify(signatureAlgorithms)},
71
+ rpEntityName : ${JSON.stringify(rpEntityName)},
72
+ rpId : ${JSON.stringify(rpId)},
73
+ attestationConveyancePreference : ${JSON.stringify(attestationConveyancePreference)},
74
+ authenticatorAttachment : ${JSON.stringify(authenticatorAttachment)},
75
+ requireResidentKey : ${JSON.stringify(requireResidentKey)},
76
+ userVerificationRequirement : ${JSON.stringify(userVerificationRequirement)},
77
+ createTimeout : ${createTimeout},
78
+ excludeCredentialIds : ${JSON.stringify(excludeCredentialIds)},
79
+ initLabel : ${JSON.stringify(i18n.value.msgStr('webauthn-registration-init-label'))},
80
+ initLabelPrompt : ${JSON.stringify(i18n.value.msgStr('webauthn-registration-init-label-prompt'))},
81
+ errmsg : ${JSON.stringify(i18n.value.msgStr('webauthn-unsupported-browser-text'))}
82
+ };
83
+ registerByWebAuthn(input);
84
+ });
85
+ `,
86
+ },
87
+ ],
88
+ });
89
+
90
+ onMounted(() => {
91
+ const stopWatch = watch(
92
+ () => i18n.value.isFetchingTranslations,
93
+ async (isFetching) => {
94
+ if (isFetching) {
95
+ return;
96
+ }
97
+
98
+ stopWatch();
99
+
100
+ await waitForElementMountedOnDom({
101
+ elementId: authButtonId,
102
+ });
103
+
104
+ insertScriptTags();
105
+ },
106
+ { immediate: true },
107
+ );
108
+ });
109
+ }
@@ -0,0 +1,105 @@
1
+ <script setup lang="ts">
2
+ import type { KcContext } from 'keycloakify/login/KcContext';
3
+ import { getKcClsx } from 'keycloakify/login/lib/kcClsx';
4
+ import { toRef } from 'vue';
5
+ import LogoutOtherSessions from '../components/LogoutOtherSessions.vue';
6
+ import type { I18n } from '../i18n/i18n';
7
+ import type { PageProps } from './PageProps';
8
+ import { useScript } from './WebauthnRegister.useScript';
9
+
10
+ const props = defineProps<PageProps<Extract<KcContext, { pageId: 'webauthn-register.ftl' }>, I18n>>();
11
+
12
+ const { kcClsx } = getKcClsx({
13
+ doUseDefaultCss: props.doUseDefaultCss,
14
+ classes: props.classes,
15
+ });
16
+
17
+ const kcContext = props.kcContext;
18
+ const { url, isSetRetry, isAppInitiatedAction } = kcContext;
19
+
20
+ const authButtonId = 'authenticateWebAuthnButton';
21
+
22
+ useScript({ authButtonId, kcContext, i18n: toRef(props, 'i18n') });
23
+ </script>
24
+
25
+ <template>
26
+ <component
27
+ :is="Template"
28
+ :kcContext="kcContext"
29
+ :i18n="props.i18n"
30
+ :doUseDefaultCss="doUseDefaultCss"
31
+ :classes="classes"
32
+ >
33
+ <template #header>
34
+ <span :class="kcClsx('kcWebAuthnKeyIcon')"></span>
35
+ <component :is="props.i18n.msg('webauthn-registration-title')" />
36
+ </template>
37
+
38
+ <form
39
+ id="register"
40
+ :class="kcClsx('kcFormClass')"
41
+ :action="url.loginAction"
42
+ method="post"
43
+ >
44
+ <div :class="kcClsx('kcFormGroupClass')">
45
+ <input
46
+ type="hidden"
47
+ id="clientDataJSON"
48
+ name="clientDataJSON"
49
+ />
50
+ <input
51
+ type="hidden"
52
+ id="attestationObject"
53
+ name="attestationObject"
54
+ />
55
+ <input
56
+ type="hidden"
57
+ id="publicKeyCredentialId"
58
+ name="publicKeyCredentialId"
59
+ />
60
+ <input
61
+ type="hidden"
62
+ id="authenticatorLabel"
63
+ name="authenticatorLabel"
64
+ />
65
+ <input
66
+ type="hidden"
67
+ id="transports"
68
+ name="transports"
69
+ />
70
+ <input
71
+ type="hidden"
72
+ id="error"
73
+ name="error"
74
+ />
75
+ <LogoutOtherSessions
76
+ :kcClsx="kcClsx"
77
+ :i18n="props.i18n"
78
+ />
79
+ </div>
80
+ </form>
81
+ <input
82
+ type="submit"
83
+ :class="kcClsx('kcButtonClass', 'kcButtonPrimaryClass', 'kcButtonBlockClass', 'kcButtonLargeClass')"
84
+ :id="authButtonId"
85
+ :value="props.i18n.msgStr('doRegisterSecurityKey')"
86
+ />
87
+ <form
88
+ v-if="!isSetRetry && isAppInitiatedAction"
89
+ :action="url.loginAction"
90
+ :class="kcClsx('kcFormClass')"
91
+ id="kc-webauthn-settings-form"
92
+ method="post"
93
+ >
94
+ <button
95
+ type="submit"
96
+ :class="kcClsx('kcButtonClass', 'kcButtonDefaultClass', 'kcButtonBlockClass', 'kcButtonLargeClass')"
97
+ id="cancelWebAuthnAIA"
98
+ name="cancel-aia"
99
+ value="true"
100
+ >
101
+ <component :is="props.i18n.msg('doCancel')" />
102
+ </button>
103
+ </form>
104
+ </component>
105
+ </template>
@@ -0,0 +1,62 @@
1
+ import { onMounted, onUnmounted, ref, type Ref } from 'vue';
2
+
3
+ const alreadyMountedComponentOrHookNames = new Set<string>();
4
+
5
+ /**
6
+ * The component using this can only be mounted once and cannot rerender with
7
+ * different hrefs. Mounting again reloads the page (mimics a server-rendered
8
+ * page importing stylesheets in the head).
9
+ */
10
+ export function useInsertLinkTags(params: { componentOrHookName: string; hrefs: string[] }): {
11
+ areAllStyleSheetsLoaded: Ref<boolean>;
12
+ } {
13
+ const { hrefs, componentOrHookName } = params;
14
+
15
+ const areAllStyleSheetsLoaded = ref(false);
16
+
17
+ onMounted(() => {
18
+ if (alreadyMountedComponentOrHookNames.has(componentOrHookName)) {
19
+ if (new URL(window.location.href).searchParams.get('viewMode') !== 'docs') {
20
+ window.location.reload();
21
+ }
22
+ return;
23
+ }
24
+ alreadyMountedComponentOrHookNames.add(componentOrHookName);
25
+ });
26
+
27
+ onMounted(() => {
28
+ let isActive = true;
29
+
30
+ (async () => {
31
+ let lastMountedHtmlElement: HTMLLinkElement | undefined = undefined;
32
+ const prs: Promise<void>[] = [];
33
+
34
+ for (const href of hrefs) {
35
+ const htmlElement = document.createElement('link');
36
+ prs.push(new Promise<void>((resolve) => htmlElement.addEventListener('load', () => resolve())));
37
+ htmlElement.rel = 'stylesheet';
38
+ htmlElement.href = href;
39
+
40
+ if (lastMountedHtmlElement !== undefined) {
41
+ lastMountedHtmlElement.insertAdjacentElement('afterend', htmlElement);
42
+ } else {
43
+ document.head.prepend(htmlElement);
44
+ }
45
+ lastMountedHtmlElement = htmlElement;
46
+ }
47
+
48
+ await Promise.all(prs);
49
+ })().then(() => {
50
+ if (!isActive) {
51
+ return;
52
+ }
53
+ areAllStyleSheetsLoaded.value = true;
54
+ });
55
+
56
+ onUnmounted(() => {
57
+ isActive = false;
58
+ });
59
+ });
60
+
61
+ return { areAllStyleSheetsLoaded };
62
+ }
@@ -0,0 +1,75 @@
1
+ import { onMounted } from 'vue';
2
+ import { assert } from 'keycloakify/tools/assert';
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-namespace
5
+ export namespace ScriptTag {
6
+ type Common = { type: 'text/javascript' | 'module' };
7
+ export type TextContent = Common & { textContent: string | (() => string) };
8
+ export type Src = Common & { src: string };
9
+ }
10
+
11
+ export type ScriptTag = ScriptTag.TextContent | ScriptTag.Src;
12
+
13
+ const alreadyMountedComponentOrHookNames = new Set<string>();
14
+
15
+ export function useInsertScriptTags(params: { componentOrHookName: string; scriptTags: ScriptTag[] }): {
16
+ insertScriptTags: () => void;
17
+ } {
18
+ const { scriptTags, componentOrHookName } = params;
19
+
20
+ onMounted(() => {
21
+ if (alreadyMountedComponentOrHookNames.has(componentOrHookName)) {
22
+ if (new URL(window.location.href).searchParams.get('viewMode') !== 'docs') {
23
+ window.location.reload();
24
+ }
25
+ return;
26
+ }
27
+ alreadyMountedComponentOrHookNames.add(componentOrHookName);
28
+ });
29
+
30
+ let areScriptsInserted = false;
31
+
32
+ const insertScriptTags = () => {
33
+ if (areScriptsInserted) {
34
+ return;
35
+ }
36
+
37
+ scriptTags.forEach((scriptTag) => {
38
+ const scripts = document.getElementsByTagName('script');
39
+ for (let i = 0; i < scripts.length; i++) {
40
+ const script = scripts[i];
41
+ if ('textContent' in scriptTag) {
42
+ const textContent =
43
+ typeof scriptTag.textContent === 'function' ? scriptTag.textContent() : scriptTag.textContent;
44
+ if (script.textContent === textContent) {
45
+ return;
46
+ }
47
+ continue;
48
+ }
49
+ if ('src' in scriptTag) {
50
+ if (script.getAttribute('src') === scriptTag.src) {
51
+ return;
52
+ }
53
+ continue;
54
+ }
55
+ assert(false);
56
+ }
57
+
58
+ const htmlElement = document.createElement('script');
59
+ htmlElement.type = scriptTag.type;
60
+ if ('textContent' in scriptTag) {
61
+ htmlElement.textContent =
62
+ typeof scriptTag.textContent === 'function' ? scriptTag.textContent() : scriptTag.textContent;
63
+ } else if ('src' in scriptTag) {
64
+ htmlElement.src = scriptTag.src;
65
+ } else {
66
+ assert(false);
67
+ }
68
+ document.head.appendChild(htmlElement);
69
+ });
70
+
71
+ areScriptsInserted = true;
72
+ };
73
+
74
+ return { insertScriptTags };
75
+ }
@@ -0,0 +1,15 @@
1
+ import { onMounted, onUnmounted } from 'vue';
2
+
3
+ export function useSetClassName(params: { qualifiedName: 'html' | 'body'; className: string | undefined }): void {
4
+ const { qualifiedName, className } = params;
5
+
6
+ onMounted(() => {
7
+ if (!className || className === '') {
8
+ return;
9
+ }
10
+ const classList = document.getElementsByTagName(qualifiedName)[0].classList;
11
+ const tokens = className.split(' ');
12
+ classList.add(...tokens);
13
+ onUnmounted(() => classList.remove(...tokens));
14
+ });
15
+ }
@@ -0,0 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
2
+ import type { ExtendKcContext } from 'keycloakify/account';
3
+ import type { KcEnvName, ThemeName } from '../kc.gen';
4
+
5
+ export type KcContextExtension = {
6
+ themeName: ThemeName;
7
+
8
+ properties: Record<KcEnvName, string> & {};
9
+ };
10
+
11
+ export type KcContextExtensionPerPage = {};
12
+
13
+ export type KcContext = ExtendKcContext<KcContextExtension, KcContextExtensionPerPage>;
@@ -0,0 +1,26 @@
1
+ import { createGetKcContextMock } from 'keycloakify/account/KcContext';
2
+ import type { DeepPartial } from 'keycloakify/tools/DeepPartial';
3
+ import { kcEnvDefaults, themeNames } from '../kc.gen';
4
+ import type { KcContext, KcContextExtension, KcContextExtensionPerPage } from './KcContext';
5
+
6
+ const kcContextExtension: KcContextExtension = {
7
+ themeName: themeNames[0],
8
+ properties: {
9
+ ...kcEnvDefaults,
10
+ },
11
+ };
12
+ const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
13
+
14
+ export const { getKcContextMock } = createGetKcContextMock({
15
+ kcContextExtension,
16
+ kcContextExtensionPerPage,
17
+ overrides: {},
18
+ overridesPerPage: {},
19
+ });
20
+
21
+ type PageId = KcContext['pageId'];
22
+
23
+ export type KcPageStoryProps = {
24
+ pageId: PageId;
25
+ kcContext?: DeepPartial<Extract<KcContext, { pageId: PageId }>>;
26
+ };