keycloakify 10.1.0-rc.1 → 10.1.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 (205) hide show
  1. package/PUBLIC_URL.js +2 -2
  2. package/PUBLIC_URL.js.map +1 -1
  3. package/account/KcContext/kcContextMocks.js +3 -3
  4. package/account/KcContext/kcContextMocks.js.map +1 -1
  5. package/bin/193.index.js +198 -62
  6. package/bin/{365.index.js → 20.index.js} +302 -263
  7. package/bin/31.index.js +15 -23
  8. package/bin/{430.index.js → 33.index.js} +579 -4
  9. package/bin/{678.index.js → 36.index.js} +2 -577
  10. package/bin/{440.index.js → 499.index.js} +259 -181
  11. package/bin/526.index.js +12 -793
  12. package/bin/599.index.js +4 -1
  13. package/bin/780.index.js +1 -1
  14. package/bin/{525.index.js → 903.index.js} +4840 -97
  15. package/bin/932.index.js +115 -886
  16. package/bin/main.js +4 -4
  17. package/bin/shared/buildContext.d.ts +0 -2
  18. package/bin/shared/buildContext.js.map +1 -1
  19. package/bin/shared/constants.d.ts +5 -6
  20. package/bin/shared/constants.js +5 -6
  21. package/bin/shared/constants.js.map +1 -1
  22. package/bin/shared/copyKeycloakResourcesToPublic.d.ts +2 -4
  23. package/bin/shared/copyKeycloakResourcesToPublic.js.map +1 -1
  24. package/login/KcContext/KcContext.d.ts +9 -18
  25. package/login/KcContext/KcContext.js.map +1 -1
  26. package/login/KcContext/kcContextMocks.js +6 -10
  27. package/login/KcContext/kcContextMocks.js.map +1 -1
  28. package/login/Template.js +4 -59
  29. package/login/Template.js.map +1 -1
  30. package/login/Template.useStylesAndScripts.d.ts +17 -0
  31. package/login/Template.useStylesAndScripts.js +69 -0
  32. package/login/Template.useStylesAndScripts.js.map +1 -0
  33. package/login/pages/Login.js +1 -1
  34. package/login/pages/Login.js.map +1 -1
  35. package/login/pages/LoginIdpLinkConfirmOverride.js +0 -1
  36. package/login/pages/LoginIdpLinkConfirmOverride.js.map +1 -1
  37. package/login/pages/LoginPasskeysConditionalAuthenticate.js +6 -49
  38. package/login/pages/LoginPasskeysConditionalAuthenticate.js.map +1 -1
  39. package/login/pages/LoginPasskeysConditionalAuthenticate.useScript.d.ts +20 -0
  40. package/login/pages/LoginPasskeysConditionalAuthenticate.useScript.js +49 -0
  41. package/login/pages/LoginPasskeysConditionalAuthenticate.useScript.js.map +1 -0
  42. package/login/pages/LoginRecoveryAuthnCodeConfig.js +4 -126
  43. package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
  44. package/login/pages/LoginRecoveryAuthnCodeConfig.useScript.d.ts +9 -0
  45. package/login/pages/LoginRecoveryAuthnCodeConfig.useScript.js +133 -0
  46. package/login/pages/LoginRecoveryAuthnCodeConfig.useScript.js.map +1 -0
  47. package/login/pages/LoginUsername.js +1 -1
  48. package/login/pages/LoginUsername.js.map +1 -1
  49. package/login/pages/Register.js +6 -3
  50. package/login/pages/Register.js.map +1 -1
  51. package/login/pages/WebauthnAuthenticate.js +13 -116
  52. package/login/pages/WebauthnAuthenticate.js.map +1 -1
  53. package/login/pages/WebauthnAuthenticate.useScript.d.ts +21 -0
  54. package/login/pages/WebauthnAuthenticate.useScript.js +41 -0
  55. package/login/pages/WebauthnAuthenticate.useScript.js.map +1 -0
  56. package/login/pages/WebauthnRegister.js +8 -178
  57. package/login/pages/WebauthnRegister.js.map +1 -1
  58. package/login/pages/WebauthnRegister.useScript.d.ts +27 -0
  59. package/login/pages/WebauthnRegister.useScript.js +49 -0
  60. package/login/pages/WebauthnRegister.useScript.js.map +1 -0
  61. package/package.json +125 -15
  62. package/res/account-v1/account.ftl +70 -0
  63. package/res/account-v1/applications.ftl +76 -0
  64. package/res/account-v1/federatedIdentity.ftl +42 -0
  65. package/res/account-v1/log.ftl +35 -0
  66. package/res/account-v1/messages/messages_ar.properties +406 -0
  67. package/res/account-v1/messages/messages_ca.properties +147 -0
  68. package/res/account-v1/messages/messages_cs.properties +171 -0
  69. package/res/account-v1/messages/messages_da.properties +339 -0
  70. package/res/account-v1/messages/messages_de.properties +353 -0
  71. package/res/account-v1/messages/messages_en.properties +404 -0
  72. package/res/account-v1/messages/messages_es.properties +147 -0
  73. package/res/account-v1/messages/messages_fi.properties +400 -0
  74. package/res/account-v1/messages/messages_fr.properties +180 -0
  75. package/res/account-v1/messages/messages_hu.properties +334 -0
  76. package/res/account-v1/messages/messages_it.properties +336 -0
  77. package/res/account-v1/messages/messages_ja.properties +335 -0
  78. package/res/account-v1/messages/messages_lt.properties +154 -0
  79. package/res/account-v1/messages/messages_lv.properties +197 -0
  80. package/res/account-v1/messages/messages_nl.properties +371 -0
  81. package/res/account-v1/messages/messages_no.properties +152 -0
  82. package/res/account-v1/messages/messages_pl.properties +248 -0
  83. package/res/account-v1/messages/messages_pt_BR.properties +349 -0
  84. package/res/account-v1/messages/messages_ru.properties +235 -0
  85. package/res/account-v1/messages/messages_sk.properties +196 -0
  86. package/res/account-v1/messages/messages_sv.properties +150 -0
  87. package/res/account-v1/messages/messages_tr.properties +315 -0
  88. package/res/account-v1/messages/messages_zh_CN.properties +153 -0
  89. package/res/account-v1/password.ftl +59 -0
  90. package/res/account-v1/resource-detail.ftl +277 -0
  91. package/res/account-v1/resources/css/account.css +277 -0
  92. package/res/account-v1/resources/img/icon-sidebar-active.png +0 -0
  93. package/res/account-v1/resources/img/keycloak-logo.png +0 -0
  94. package/res/account-v1/resources/img/logo.png +0 -0
  95. package/res/account-v1/resources/resources-common/img/favicon.ico +0 -0
  96. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  97. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  98. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  99. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  100. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  101. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  102. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  103. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  104. package/res/account-v1/resources.ftl +403 -0
  105. package/res/account-v1/sessions.ftl +44 -0
  106. package/res/account-v1/template.ftl +88 -0
  107. package/res/account-v1/theme.properties +14 -0
  108. package/res/account-v1/totp.ftl +141 -0
  109. package/res/public/.keycloakify/account/css/account.css +277 -0
  110. package/res/public/.keycloakify/account/img/icon-sidebar-active.png +0 -0
  111. package/res/public/.keycloakify/account/img/keycloak-logo.png +0 -0
  112. package/res/public/.keycloakify/account/img/logo.png +0 -0
  113. package/res/public/.keycloakify/account/resources-common/img/favicon.ico +0 -0
  114. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  115. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  116. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  117. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  118. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  119. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  120. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  121. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  122. package/res/public/.keycloakify/login/css/login.css +629 -0
  123. package/res/public/.keycloakify/login/img/feedback-error-arrow-down.png +0 -0
  124. package/res/public/.keycloakify/login/img/feedback-error-sign.png +0 -0
  125. package/res/public/.keycloakify/login/img/feedback-success-arrow-down.png +0 -0
  126. package/res/public/.keycloakify/login/img/feedback-success-sign.png +0 -0
  127. package/res/public/.keycloakify/login/img/feedback-warning-arrow-down.png +0 -0
  128. package/res/public/.keycloakify/login/img/feedback-warning-sign.png +0 -0
  129. package/res/public/.keycloakify/login/img/keycloak-bg.png +0 -0
  130. package/res/public/.keycloakify/login/img/keycloak-logo-text.png +0 -0
  131. package/res/public/.keycloakify/login/img/keycloak-logo.png +0 -0
  132. package/res/public/.keycloakify/login/js/authChecker.js +49 -0
  133. package/res/public/.keycloakify/login/js/common.js +48 -0
  134. package/res/public/.keycloakify/login/js/kcMultivalued.js +106 -0
  135. package/res/public/.keycloakify/login/js/kcNumberFormat.js +21 -0
  136. package/res/public/.keycloakify/login/js/kcNumberUnFormat.js +19 -0
  137. package/res/public/.keycloakify/login/js/menu-button-links.js +315 -0
  138. package/{src/bin/shared/downloadKeycloakDefaultTheme/extra-assets → res/public/.keycloakify/login/js}/passkeysConditionalAuth.js +1 -1
  139. package/res/public/.keycloakify/login/js/passwordVisibility.js +15 -0
  140. package/res/public/.keycloakify/login/js/userProfile.js +71 -0
  141. package/res/public/.keycloakify/login/js/webauthnRegister.js +140 -0
  142. package/res/public/.keycloakify/login/resources-common/img/favicon.ico +0 -0
  143. package/res/public/.keycloakify/login/resources-common/lib/pficon/pficon.css +22 -0
  144. package/res/public/.keycloakify/login/resources-common/lib/pficon/pficon.woff2 +0 -0
  145. package/res/public/.keycloakify/login/resources-common/node_modules/@patternfly/patternfly/patternfly.min.css +2 -0
  146. package/res/public/.keycloakify/login/resources-common/node_modules/jquery/dist/jquery.min.js +2 -0
  147. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  148. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  149. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.ttf +0 -0
  150. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff +0 -0
  151. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  152. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  153. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  154. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  155. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  156. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  157. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/fontawesome-webfont.woff2 +0 -0
  158. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/img/bg-login.jpg +0 -0
  159. package/res/public/.keycloakify/login/resources-common/node_modules/rfc4648/lib/rfc4648.js +178 -0
  160. package/src/PUBLIC_URL.ts +5 -3
  161. package/src/account/KcContext/kcContextMocks.ts +3 -3
  162. package/src/bin/copy-keycloak-resources-to-public.ts +1 -1
  163. package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +4 -1
  164. package/src/bin/initialize-email-theme.ts +28 -8
  165. package/src/bin/keycloakify/buildJars/buildJar.ts +3 -7
  166. package/src/bin/keycloakify/generateFtl/generateFtl.ts +3 -7
  167. package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +65 -90
  168. package/src/bin/keycloakify/keycloakify.ts +38 -21
  169. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +2 -2
  170. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +3 -3
  171. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +3 -3
  172. package/src/bin/shared/buildContext.ts +1 -8
  173. package/src/bin/shared/constants.ts +5 -7
  174. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +30 -40
  175. package/src/bin/start-keycloak/start-keycloak.ts +10 -12
  176. package/src/login/KcContext/KcContext.ts +9 -18
  177. package/src/login/KcContext/kcContextMocks.ts +5 -13
  178. package/src/login/Template.tsx +4 -67
  179. package/src/login/Template.useStylesAndScripts.ts +94 -0
  180. package/src/login/pages/Login.tsx +1 -1
  181. package/src/login/pages/LoginIdpLinkConfirmOverride.tsx +0 -1
  182. package/src/login/pages/LoginPasskeysConditionalAuthenticate.tsx +6 -81
  183. package/src/login/pages/LoginPasskeysConditionalAuthenticate.useScript.tsx +72 -0
  184. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +4 -126
  185. package/src/login/pages/LoginRecoveryAuthnCodeConfig.useScript.tsx +142 -0
  186. package/src/login/pages/LoginUsername.tsx +1 -1
  187. package/src/login/pages/Register.tsx +35 -13
  188. package/src/login/pages/WebauthnAuthenticate.tsx +20 -133
  189. package/src/login/pages/WebauthnAuthenticate.useScript.tsx +64 -0
  190. package/src/login/pages/WebauthnRegister.tsx +8 -195
  191. package/src/login/pages/WebauthnRegister.useScript.tsx +93 -0
  192. package/src/tools/useInsertScriptTags.ts +14 -4
  193. package/src/vite-plugin/vite-plugin.ts +11 -15
  194. package/tools/useInsertScriptTags.d.ts +2 -2
  195. package/tools/useInsertScriptTags.js +8 -2
  196. package/tools/useInsertScriptTags.js.map +1 -1
  197. package/vite-plugin/index.js +3357 -47132
  198. package/bin/697.index.js +0 -4749
  199. package/bin/shared/downloadKeycloakStaticResources.d.ts +0 -9
  200. package/bin/shared/downloadKeycloakStaticResources.js.map +0 -1
  201. package/src/bin/keycloakify/generateResources/bringInAccountV1.ts +0 -89
  202. package/src/bin/shared/downloadKeycloakDefaultTheme/downloadKeycloakDefaultTheme.ts +0 -338
  203. package/src/bin/shared/downloadKeycloakDefaultTheme/index.ts +0 -1
  204. package/src/bin/shared/downloadKeycloakStaticResources.ts +0 -53
  205. /package/{src/bin/shared/downloadKeycloakDefaultTheme/extra-assets → res/public/.keycloakify/login/js}/webauthnAuthenticate.js +0 -0
@@ -1,9 +0,0 @@
1
- import { type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme } from "./downloadKeycloakDefaultTheme";
2
- import { type ThemeType } from "./constants";
3
- export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
4
- export declare function downloadKeycloakStaticResources(params: {
5
- themeType: ThemeType;
6
- themeDirPath: string;
7
- keycloakVersion: string;
8
- buildContext: BuildContextLike;
9
- }): Promise<void>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"downloadKeycloakStaticResources.js","sourceRoot":"","sources":["../../src/bin/shared/downloadKeycloakStaticResources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EACH,4BAA4B,EAE/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAkB,MAAM,aAAa,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,MAAM,EAAwD,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,MAKrD;IACG,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAE1E,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,4BAA4B,CAAC;QAC/D,eAAe;QACf,YAAY;KACf,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,QAAQ,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAExE,yBAAyB,EAAE;QACvB,MAAM,UAAU,GAAG,QAAQ,CAAC,mBAAmB,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QAEjF,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE;YAClC,MAAM,yBAAyB,CAAC;SACnC;QAED,iBAAiB,CAAC;YACd,UAAU;YACV,WAAW,EAAE,gBAAgB;SAChC,CAAC,CAAC;KACN;IAED,iBAAiB,CAAC;QACd,UAAU,EAAE,QAAQ,CAAC,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC;QAC7E,WAAW,EAAE,gBAAgB;KAChC,CAAC,CAAC;IAEH,iBAAiB,CAAC;QACd,UAAU,EAAE,QAAQ,CAAC,mBAAmB,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC;QAC5E,WAAW,EAAE,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;KAC5D,CAAC,CAAC;AACP,CAAC"}
@@ -1,89 +0,0 @@
1
- import * as fs from "fs";
2
- import { join as pathJoin } from "path";
3
- import { assert } from "tsafe/assert";
4
- import type { BuildContext } from "../../shared/buildContext";
5
- import {
6
- RESOURCES_COMMON,
7
- LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
8
- ACCOUNT_V1_THEME_NAME
9
- } from "../../shared/constants";
10
- import {
11
- downloadKeycloakDefaultTheme,
12
- BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
13
- } from "../../shared/downloadKeycloakDefaultTheme";
14
- import { transformCodebase } from "../../tools/transformCodebase";
15
-
16
- export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme;
17
-
18
- assert<BuildContext extends BuildContextLike ? true : false>();
19
-
20
- export async function bringInAccountV1(params: {
21
- resourcesDirPath: string;
22
- buildContext: BuildContextLike;
23
- }) {
24
- const { resourcesDirPath, buildContext } = params;
25
-
26
- const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
27
- keycloakVersion: LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
28
- buildContext
29
- });
30
-
31
- const accountV1DirPath = pathJoin(
32
- resourcesDirPath,
33
- "theme",
34
- ACCOUNT_V1_THEME_NAME,
35
- "account"
36
- );
37
-
38
- transformCodebase({
39
- srcDirPath: pathJoin(defaultThemeDirPath, "base", "account"),
40
- destDirPath: accountV1DirPath
41
- });
42
-
43
- transformCodebase({
44
- srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "account", "resources"),
45
- destDirPath: pathJoin(accountV1DirPath, "resources")
46
- });
47
-
48
- transformCodebase({
49
- srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
50
- destDirPath: pathJoin(accountV1DirPath, "resources", RESOURCES_COMMON)
51
- });
52
-
53
- fs.writeFileSync(
54
- pathJoin(accountV1DirPath, "theme.properties"),
55
- Buffer.from(
56
- [
57
- "accountResourceProvider=account-v1",
58
- "",
59
- "locales=ar,ca,cs,da,de,en,es,fr,fi,hu,it,ja,lt,nl,no,pl,pt-BR,ru,sk,sv,tr,zh-CN",
60
- "",
61
- "styles=" +
62
- [
63
- "css/account.css",
64
- "img/icon-sidebar-active.png",
65
- "img/logo.png",
66
- ...[
67
- "patternfly.min.css",
68
- "patternfly-additions.min.css",
69
- "patternfly-additions.min.css"
70
- ].map(
71
- fileBasename =>
72
- `${RESOURCES_COMMON}/node_modules/patternfly/dist/css/${fileBasename}`
73
- )
74
- ].join(" "),
75
- "",
76
- "##### css classes for form buttons",
77
- "# main class used for all buttons",
78
- "kcButtonClass=btn",
79
- "# classes defining priority of the button - primary or default (there is typically only one priority button for the form)",
80
- "kcButtonPrimaryClass=btn-primary",
81
- "kcButtonDefaultClass=btn-default",
82
- "# classes defining size of the button",
83
- "kcButtonLargeClass=btn-lg",
84
- ""
85
- ].join("\n"),
86
- "utf8"
87
- )
88
- );
89
- }
@@ -1,338 +0,0 @@
1
- import { join as pathJoin, relative as pathRelative } from "path";
2
- import { type BuildContext } from "../buildContext";
3
- import { assert } from "tsafe/assert";
4
- import { LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 } from "../constants";
5
- import { downloadAndExtractArchive } from "../../tools/downloadAndExtractArchive";
6
- import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
7
- import * as fsPr from "fs/promises";
8
-
9
- export type BuildContextLike = {
10
- cacheDirPath: string;
11
- fetchOptions: BuildContext["fetchOptions"];
12
- };
13
-
14
- assert<BuildContext extends BuildContextLike ? true : false>();
15
-
16
- export async function downloadKeycloakDefaultTheme(params: {
17
- keycloakVersion: string;
18
- buildContext: BuildContextLike;
19
- }): Promise<{ defaultThemeDirPath: string }> {
20
- const { keycloakVersion, buildContext } = params;
21
-
22
- let kcNodeModulesKeepFilePaths: Set<string> | undefined = undefined;
23
- let kcNodeModulesKeepFilePaths_lastAccountV1: Set<string> | undefined = undefined;
24
-
25
- let areExtraAssetsFor24Copied = false;
26
-
27
- const { extractedDirPath } = await downloadAndExtractArchive({
28
- url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
29
- cacheDirPath: buildContext.cacheDirPath,
30
- fetchOptions: buildContext.fetchOptions,
31
- uniqueIdOfOnArchiveFile: "downloadKeycloakDefaultTheme",
32
- onArchiveFile: async params => {
33
- const fileRelativePath = pathRelative("theme", params.fileRelativePath);
34
-
35
- if (fileRelativePath.startsWith("..")) {
36
- return;
37
- }
38
-
39
- skip_keycloak_v2: {
40
- if (!fileRelativePath.startsWith(pathJoin("keycloak.v2"))) {
41
- break skip_keycloak_v2;
42
- }
43
-
44
- return;
45
- }
46
-
47
- const { readFile, writeFile } = params;
48
-
49
- last_account_v1_transformations: {
50
- if (LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 !== keycloakVersion) {
51
- break last_account_v1_transformations;
52
- }
53
-
54
- skip_web_modules: {
55
- if (
56
- !fileRelativePath.startsWith(
57
- pathJoin("keycloak", "common", "resources", "web_modules")
58
- )
59
- ) {
60
- break skip_web_modules;
61
- }
62
-
63
- return;
64
- }
65
-
66
- skip_lib: {
67
- if (
68
- !fileRelativePath.startsWith(
69
- pathJoin("keycloak", "common", "resources", "lib")
70
- )
71
- ) {
72
- break skip_lib;
73
- }
74
-
75
- return;
76
- }
77
-
78
- skip_node_modules: {
79
- const nodeModulesRelativeDirPath = pathJoin(
80
- "keycloak",
81
- "common",
82
- "resources",
83
- "node_modules"
84
- );
85
-
86
- if (!fileRelativePath.startsWith(nodeModulesRelativeDirPath)) {
87
- break skip_node_modules;
88
- }
89
-
90
- if (kcNodeModulesKeepFilePaths_lastAccountV1 === undefined) {
91
- kcNodeModulesKeepFilePaths_lastAccountV1 = new Set([
92
- pathJoin("patternfly", "dist", "css", "patternfly.min.css"),
93
- pathJoin(
94
- "patternfly",
95
- "dist",
96
- "css",
97
- "patternfly-additions.min.css"
98
- ),
99
- pathJoin(
100
- "patternfly",
101
- "dist",
102
- "fonts",
103
- "OpenSans-Regular-webfont.woff2"
104
- ),
105
- pathJoin(
106
- "patternfly",
107
- "dist",
108
- "fonts",
109
- "OpenSans-Bold-webfont.woff2"
110
- ),
111
- pathJoin(
112
- "patternfly",
113
- "dist",
114
- "fonts",
115
- "OpenSans-Light-webfont.woff2"
116
- ),
117
- pathJoin(
118
- "patternfly",
119
- "dist",
120
- "fonts",
121
- "OpenSans-Semibold-webfont.woff2"
122
- ),
123
- pathJoin(
124
- "patternfly",
125
- "dist",
126
- "fonts",
127
- "PatternFlyIcons-webfont.ttf"
128
- ),
129
- pathJoin(
130
- "patternfly",
131
- "dist",
132
- "fonts",
133
- "PatternFlyIcons-webfont.woff"
134
- )
135
- ]);
136
- }
137
-
138
- const fileRelativeToNodeModulesPath = fileRelativePath.substring(
139
- nodeModulesRelativeDirPath.length + 1
140
- );
141
-
142
- if (
143
- kcNodeModulesKeepFilePaths_lastAccountV1.has(
144
- fileRelativeToNodeModulesPath
145
- )
146
- ) {
147
- break skip_node_modules;
148
- }
149
-
150
- return;
151
- }
152
-
153
- patch_account_css: {
154
- if (
155
- fileRelativePath !==
156
- pathJoin("keycloak", "account", "resources", "css", "account.css")
157
- ) {
158
- break patch_account_css;
159
- }
160
-
161
- await writeFile({
162
- fileRelativePath,
163
- modifiedData: Buffer.from(
164
- (await readFile())
165
- .toString("utf8")
166
- .replace("top: -34px;", "top: -34px !important;"),
167
- "utf8"
168
- )
169
- });
170
-
171
- return;
172
- }
173
- }
174
-
175
- copy_extra_assets: {
176
- if (keycloakVersion !== "24.0.4") {
177
- break copy_extra_assets;
178
- }
179
-
180
- if (areExtraAssetsFor24Copied) {
181
- break copy_extra_assets;
182
- }
183
-
184
- const extraAssetsDirPath = pathJoin(
185
- getThisCodebaseRootDirPath(),
186
- "src",
187
- "bin",
188
- "shared",
189
- "downloadKeycloakDefaultTheme",
190
- "extra-assets"
191
- );
192
-
193
- await Promise.all(
194
- ["webauthnAuthenticate.js", "passkeysConditionalAuth.js"].map(
195
- async fileBasename =>
196
- writeFile({
197
- fileRelativePath: pathJoin(
198
- "base",
199
- "login",
200
- "resources",
201
- "js",
202
- fileBasename
203
- ),
204
- modifiedData: await fsPr.readFile(
205
- pathJoin(extraAssetsDirPath, fileBasename)
206
- )
207
- })
208
- )
209
- );
210
- }
211
-
212
- skip_unused_resources: {
213
- if (keycloakVersion !== "24.0.4") {
214
- break skip_unused_resources;
215
- }
216
-
217
- skip_node_modules: {
218
- const nodeModulesRelativeDirPath = pathJoin(
219
- "keycloak",
220
- "common",
221
- "resources",
222
- "node_modules"
223
- );
224
-
225
- if (!fileRelativePath.startsWith(nodeModulesRelativeDirPath)) {
226
- break skip_node_modules;
227
- }
228
-
229
- if (kcNodeModulesKeepFilePaths === undefined) {
230
- kcNodeModulesKeepFilePaths = new Set([
231
- pathJoin("@patternfly", "patternfly", "patternfly.min.css"),
232
- pathJoin("patternfly", "dist", "css", "patternfly.min.css"),
233
- pathJoin(
234
- "patternfly",
235
- "dist",
236
- "css",
237
- "patternfly-additions.min.css"
238
- ),
239
- pathJoin(
240
- "patternfly",
241
- "dist",
242
- "fonts",
243
- "OpenSans-Regular-webfont.woff2"
244
- ),
245
- pathJoin(
246
- "patternfly",
247
- "dist",
248
- "fonts",
249
- "OpenSans-Light-webfont.woff2"
250
- ),
251
- pathJoin(
252
- "patternfly",
253
- "dist",
254
- "fonts",
255
- "OpenSans-Bold-webfont.woff2"
256
- ),
257
- pathJoin(
258
- "patternfly",
259
- "dist",
260
- "fonts",
261
- "OpenSans-Bold-webfont.woff"
262
- ),
263
- pathJoin(
264
- "patternfly",
265
- "dist",
266
- "fonts",
267
- "OpenSans-Bold-webfont.ttf"
268
- ),
269
- pathJoin(
270
- "patternfly",
271
- "dist",
272
- "fonts",
273
- "fontawesome-webfont.woff2"
274
- ),
275
- pathJoin(
276
- "patternfly",
277
- "dist",
278
- "fonts",
279
- "PatternFlyIcons-webfont.ttf"
280
- ),
281
- pathJoin(
282
- "patternfly",
283
- "dist",
284
- "fonts",
285
- "PatternFlyIcons-webfont.woff"
286
- ),
287
- pathJoin(
288
- "patternfly",
289
- "dist",
290
- "fonts",
291
- "OpenSans-Semibold-webfont.woff2"
292
- ),
293
- pathJoin("patternfly", "dist", "img", "bg-login.jpg"),
294
- pathJoin("jquery", "dist", "jquery.min.js")
295
- ]);
296
- }
297
-
298
- const fileRelativeToNodeModulesPath = fileRelativePath.substring(
299
- nodeModulesRelativeDirPath.length + 1
300
- );
301
-
302
- if (kcNodeModulesKeepFilePaths.has(fileRelativeToNodeModulesPath)) {
303
- break skip_node_modules;
304
- }
305
-
306
- return;
307
- }
308
-
309
- skip_vendor: {
310
- if (
311
- !fileRelativePath.startsWith(
312
- pathJoin("keycloak", "common", "resources", "vendor")
313
- )
314
- ) {
315
- break skip_vendor;
316
- }
317
-
318
- return;
319
- }
320
-
321
- skip_rollup_config: {
322
- if (
323
- fileRelativePath !==
324
- pathJoin("keycloak", "common", "resources", "rollup.config.js")
325
- ) {
326
- break skip_rollup_config;
327
- }
328
-
329
- return;
330
- }
331
- }
332
-
333
- await writeFile({ fileRelativePath });
334
- }
335
- });
336
-
337
- return { defaultThemeDirPath: extractedDirPath };
338
- }
@@ -1 +0,0 @@
1
- export * from "./downloadKeycloakDefaultTheme";
@@ -1,53 +0,0 @@
1
- import { transformCodebase } from "../tools/transformCodebase";
2
- import { join as pathJoin } from "path";
3
- import {
4
- downloadKeycloakDefaultTheme,
5
- type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
6
- } from "./downloadKeycloakDefaultTheme";
7
- import { RESOURCES_COMMON, type ThemeType } from "./constants";
8
- import type { BuildContext } from "./buildContext";
9
- import { assert } from "tsafe/assert";
10
- import { existsAsync } from "../tools/fs.existsAsync";
11
-
12
- export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
13
-
14
- assert<BuildContext extends BuildContextLike ? true : false>();
15
-
16
- export async function downloadKeycloakStaticResources(params: {
17
- themeType: ThemeType;
18
- themeDirPath: string;
19
- keycloakVersion: string;
20
- buildContext: BuildContextLike;
21
- }) {
22
- const { themeType, themeDirPath, keycloakVersion, buildContext } = params;
23
-
24
- const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
25
- keycloakVersion,
26
- buildContext
27
- });
28
-
29
- const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
30
-
31
- repatriate_base_resources: {
32
- const srcDirPath = pathJoin(defaultThemeDirPath, "base", themeType, "resources");
33
-
34
- if (!(await existsAsync(srcDirPath))) {
35
- break repatriate_base_resources;
36
- }
37
-
38
- transformCodebase({
39
- srcDirPath,
40
- destDirPath: resourcesDirPath
41
- });
42
- }
43
-
44
- transformCodebase({
45
- srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", themeType, "resources"),
46
- destDirPath: resourcesDirPath
47
- });
48
-
49
- transformCodebase({
50
- srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
51
- destDirPath: pathJoin(resourcesDirPath, RESOURCES_COMMON)
52
- });
53
- }