keycloakify 2.3.0 → 2.5.2

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 (177) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +156 -127
  3. package/bin/KeycloakVersion.js.map +1 -1
  4. package/bin/build-keycloak-theme/build-keycloak-theme.js +57 -54
  5. package/bin/build-keycloak-theme/build-keycloak-theme.js.map +1 -1
  6. package/bin/build-keycloak-theme/ftlValuesGlobalName.js.map +1 -1
  7. package/bin/build-keycloak-theme/generateDebugFiles/generateDebugFiles.js +4 -11
  8. package/bin/build-keycloak-theme/generateDebugFiles/generateDebugFiles.js.map +1 -1
  9. package/bin/build-keycloak-theme/generateFtl/common.ftl +72 -57
  10. package/bin/build-keycloak-theme/generateFtl/generateFtl.d.ts +1 -1
  11. package/bin/build-keycloak-theme/generateFtl/generateFtl.js +47 -44
  12. package/bin/build-keycloak-theme/generateFtl/generateFtl.js.map +1 -1
  13. package/bin/build-keycloak-theme/generateJavaStackFiles.js +12 -8
  14. package/bin/build-keycloak-theme/generateJavaStackFiles.js.map +1 -1
  15. package/bin/build-keycloak-theme/generateKeycloakThemeResources.js +20 -21
  16. package/bin/build-keycloak-theme/generateKeycloakThemeResources.js.map +1 -1
  17. package/bin/build-keycloak-theme/index.js.map +1 -1
  18. package/bin/build-keycloak-theme/replaceImportFromStatic.js +18 -30
  19. package/bin/build-keycloak-theme/replaceImportFromStatic.js.map +1 -1
  20. package/bin/download-builtin-keycloak-theme.js +2 -2
  21. package/bin/download-builtin-keycloak-theme.js.map +1 -1
  22. package/bin/generate-i18n-messages.js +9 -11
  23. package/bin/generate-i18n-messages.js.map +1 -1
  24. package/bin/link_in_test_app.js +6 -22
  25. package/bin/link_in_test_app.js.map +1 -1
  26. package/bin/tools/crawl.js.map +1 -1
  27. package/bin/tools/downloadAndUnzip.js +4 -5
  28. package/bin/tools/downloadAndUnzip.js.map +1 -1
  29. package/bin/tools/grant-exec-perms.js +4 -3
  30. package/bin/tools/grant-exec-perms.js.map +1 -1
  31. package/bin/tools/isInside.js.map +1 -1
  32. package/bin/tools/rm.js +1 -1
  33. package/bin/tools/rm.js.map +1 -1
  34. package/bin/tools/transformCodebase.js +7 -3
  35. package/bin/tools/transformCodebase.js.map +1 -1
  36. package/lib/components/Error.js +1 -2
  37. package/lib/components/Error.js.map +1 -1
  38. package/lib/components/Info.js +1 -15
  39. package/lib/components/Info.js.map +1 -1
  40. package/lib/components/KcApp.js +23 -10
  41. package/lib/components/KcApp.js.map +1 -1
  42. package/lib/components/KcProps.d.ts +4 -2
  43. package/lib/components/KcProps.js +10 -8
  44. package/lib/components/KcProps.js.map +1 -1
  45. package/lib/components/Login.js +20 -18
  46. package/lib/components/Login.js.map +1 -1
  47. package/lib/components/LoginIdpLinkConfirm.js.map +1 -1
  48. package/lib/components/LoginOtp.js +14 -15
  49. package/lib/components/LoginOtp.js.map +1 -1
  50. package/lib/components/LoginResetPassword.js +5 -7
  51. package/lib/components/LoginResetPassword.js.map +1 -1
  52. package/lib/components/LoginUpdateProfile.js +1 -5
  53. package/lib/components/LoginUpdateProfile.js.map +1 -1
  54. package/lib/components/LoginVerifyEmail.js.map +1 -1
  55. package/lib/components/Register.js +1 -4
  56. package/lib/components/Register.js.map +1 -1
  57. package/lib/components/RegisterUserProfile.d.ts +6 -0
  58. package/lib/components/RegisterUserProfile.js +78 -0
  59. package/lib/components/RegisterUserProfile.js.map +1 -0
  60. package/lib/components/Template.js +28 -43
  61. package/lib/components/Template.js.map +1 -1
  62. package/lib/components/Terms.js.map +1 -1
  63. package/lib/getKcContext/KcContextBase.d.ts +78 -18
  64. package/lib/getKcContext/KcContextBase.js +2 -3
  65. package/lib/getKcContext/KcContextBase.js.map +1 -1
  66. package/lib/getKcContext/getKcContext.d.ts +1 -3
  67. package/lib/getKcContext/getKcContext.js +5 -9
  68. package/lib/getKcContext/getKcContext.js.map +1 -1
  69. package/lib/getKcContext/kcContextMocks/kcContextMocks.d.ts +1 -0
  70. package/lib/getKcContext/kcContextMocks/kcContextMocks.js +187 -55
  71. package/lib/getKcContext/kcContextMocks/kcContextMocks.js.map +1 -1
  72. package/lib/getKcContext/kcContextMocks/urlResourcesPath.js.map +1 -1
  73. package/lib/i18n/KcLanguageTag.d.ts +25 -2
  74. package/lib/i18n/KcLanguageTag.js +27 -27
  75. package/lib/i18n/KcLanguageTag.js.map +1 -1
  76. package/lib/i18n/generated_kcMessages/11.0.3/account.js +27 -27
  77. package/lib/i18n/generated_kcMessages/11.0.3/account.js.map +1 -1
  78. package/lib/i18n/generated_kcMessages/11.0.3/admin.js +23 -23
  79. package/lib/i18n/generated_kcMessages/11.0.3/admin.js.map +1 -1
  80. package/lib/i18n/generated_kcMessages/11.0.3/email.js +97 -97
  81. package/lib/i18n/generated_kcMessages/11.0.3/email.js.map +1 -1
  82. package/lib/i18n/generated_kcMessages/11.0.3/login.js +30 -30
  83. package/lib/i18n/generated_kcMessages/11.0.3/login.js.map +1 -1
  84. package/lib/i18n/generated_kcMessages/15.0.2/account.js +29 -29
  85. package/lib/i18n/generated_kcMessages/15.0.2/account.js.map +1 -1
  86. package/lib/i18n/generated_kcMessages/15.0.2/admin.js +23 -23
  87. package/lib/i18n/generated_kcMessages/15.0.2/admin.js.map +1 -1
  88. package/lib/i18n/generated_kcMessages/15.0.2/email.js +111 -111
  89. package/lib/i18n/generated_kcMessages/15.0.2/email.js.map +1 -1
  90. package/lib/i18n/generated_kcMessages/15.0.2/login.js +32 -32
  91. package/lib/i18n/generated_kcMessages/15.0.2/login.js.map +1 -1
  92. package/lib/i18n/kcMessages/login.js +1 -1
  93. package/lib/i18n/kcMessages/login.js.map +1 -1
  94. package/lib/i18n/useKcLanguageTag.js +1 -3
  95. package/lib/i18n/useKcLanguageTag.js.map +1 -1
  96. package/lib/i18n/useKcMessage.d.ts +2 -1
  97. package/lib/i18n/useKcMessage.js +8 -6
  98. package/lib/i18n/useKcMessage.js.map +1 -1
  99. package/lib/keycloakJsAdapter.d.ts +6 -6
  100. package/lib/keycloakJsAdapter.js +10 -12
  101. package/lib/keycloakJsAdapter.js.map +1 -1
  102. package/lib/tools/ReactComponent.d.ts +2 -0
  103. package/lib/tools/ReactComponent.js +3 -0
  104. package/lib/tools/ReactComponent.js.map +1 -0
  105. package/lib/tools/allPropertiesValuesToUndefined.js +1 -2
  106. package/lib/tools/allPropertiesValuesToUndefined.js.map +1 -1
  107. package/lib/tools/appendHead.js +16 -12
  108. package/lib/tools/appendHead.js.map +1 -1
  109. package/lib/tools/assert.js.map +1 -1
  110. package/lib/tools/deepAssign.js +3 -4
  111. package/lib/tools/deepAssign.js.map +1 -1
  112. package/lib/tools/deepClone.js.map +1 -1
  113. package/package.json +26 -6
  114. package/src/bin/KeycloakVersion.ts +0 -2
  115. package/src/bin/build-keycloak-theme/build-keycloak-theme.ts +70 -77
  116. package/src/bin/build-keycloak-theme/ftlValuesGlobalName.ts +1 -2
  117. package/src/bin/build-keycloak-theme/generateDebugFiles/generateDebugFiles.ts +26 -37
  118. package/src/bin/build-keycloak-theme/generateDebugFiles/index.ts +1 -1
  119. package/src/bin/build-keycloak-theme/generateFtl/common.ftl +72 -57
  120. package/src/bin/build-keycloak-theme/generateFtl/generateFtl.ts +75 -95
  121. package/src/bin/build-keycloak-theme/generateFtl/index.ts +1 -1
  122. package/src/bin/build-keycloak-theme/generateJavaStackFiles.ts +38 -56
  123. package/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts +47 -85
  124. package/src/bin/build-keycloak-theme/index.ts +2 -4
  125. package/src/bin/build-keycloak-theme/replaceImportFromStatic.ts +34 -78
  126. package/src/bin/download-builtin-keycloak-theme.ts +5 -19
  127. package/src/bin/generate-i18n-messages.ts +13 -25
  128. package/src/bin/link_in_test_app.ts +9 -38
  129. package/src/bin/tools/crawl.ts +2 -12
  130. package/src/bin/tools/downloadAndUnzip.ts +6 -22
  131. package/src/bin/tools/getProjectRoot.ts +1 -1
  132. package/src/bin/tools/grant-exec-perms.ts +8 -7
  133. package/src/bin/tools/isInside.ts +2 -9
  134. package/src/bin/tools/rm.ts +21 -32
  135. package/src/bin/tools/transformCodebase.ts +20 -43
  136. package/src/lib/components/Error.tsx +3 -7
  137. package/src/lib/components/Info.tsx +23 -47
  138. package/src/lib/components/KcApp.tsx +25 -13
  139. package/src/lib/components/KcProps.ts +94 -92
  140. package/src/lib/components/Login.tsx +126 -116
  141. package/src/lib/components/LoginIdpLinkConfirm.tsx +38 -53
  142. package/src/lib/components/LoginOtp.tsx +39 -76
  143. package/src/lib/components/LoginResetPassword.tsx +9 -26
  144. package/src/lib/components/LoginUpdateProfile.tsx +104 -117
  145. package/src/lib/components/LoginVerifyEmail.tsx +3 -12
  146. package/src/lib/components/Register.tsx +76 -46
  147. package/src/lib/components/RegisterUserProfile.tsx +201 -0
  148. package/src/lib/components/Template.tsx +109 -161
  149. package/src/lib/components/Terms.tsx +4 -13
  150. package/src/lib/getKcContext/KcContextBase.ts +104 -53
  151. package/src/lib/getKcContext/getKcContext.ts +47 -78
  152. package/src/lib/getKcContext/index.ts +2 -2
  153. package/src/lib/getKcContext/kcContextMocks/index.ts +1 -1
  154. package/src/lib/getKcContext/kcContextMocks/kcContextMocks.ts +362 -241
  155. package/src/lib/getKcContext/kcContextMocks/urlResourcesPath.ts +1 -2
  156. package/src/lib/i18n/KcLanguageTag.ts +34 -45
  157. package/src/lib/i18n/generated_kcMessages/11.0.3/account.ts +3086 -3059
  158. package/src/lib/i18n/generated_kcMessages/11.0.3/admin.ts +248 -239
  159. package/src/lib/i18n/generated_kcMessages/11.0.3/email.ts +848 -633
  160. package/src/lib/i18n/generated_kcMessages/11.0.3/login.ts +4466 -4359
  161. package/src/lib/i18n/generated_kcMessages/15.0.2/account.ts +4247 -4202
  162. package/src/lib/i18n/generated_kcMessages/15.0.2/admin.ts +273 -264
  163. package/src/lib/i18n/generated_kcMessages/15.0.2/email.ts +997 -749
  164. package/src/lib/i18n/generated_kcMessages/15.0.2/login.ts +5352 -5212
  165. package/src/lib/i18n/kcMessages/login.ts +4 -9
  166. package/src/lib/i18n/useKcLanguageTag.ts +2 -16
  167. package/src/lib/i18n/useKcMessage.tsx +17 -20
  168. package/src/lib/index.ts +0 -1
  169. package/src/lib/keycloakJsAdapter.ts +23 -53
  170. package/src/lib/tools/AndByDiscriminatingKey.ts +16 -30
  171. package/src/lib/tools/DeepPartial.ts +1 -2
  172. package/src/lib/tools/ReactComponent.ts +4 -0
  173. package/src/lib/tools/allPropertiesValuesToUndefined.ts +1 -6
  174. package/src/lib/tools/appendHead.ts +28 -25
  175. package/src/lib/tools/assert.ts +1 -2
  176. package/src/lib/tools/deepAssign.ts +28 -46
  177. package/src/lib/tools/deepClone.ts +2 -3
@@ -20,7 +20,10 @@ const parsedPackageJson: ParsedPackageJson = require(pathJoin(reactProjectDirPat
20
20
  export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
21
21
 
22
22
  function sanitizeThemeName(name: string) {
23
- return name.replace(/^@(.*)/, '$1').split('/').join('-');
23
+ return name
24
+ .replace(/^@(.*)/, "$1")
25
+ .split("/")
26
+ .join("-");
24
27
  }
25
28
 
26
29
  export function main() {
@@ -35,105 +38,95 @@ export function main() {
35
38
  "reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
36
39
  themeName,
37
40
  ...(() => {
38
-
39
41
  const url = (() => {
40
-
41
42
  const { homepage } = parsedPackageJson;
42
43
 
43
- return homepage === undefined ?
44
- undefined :
45
- new URL(homepage);
46
-
44
+ return homepage === undefined ? undefined : new URL(homepage);
47
45
  })();
48
46
 
49
47
  return {
50
- "urlPathname":
51
- url === undefined ?
52
- "/" :
53
- url.pathname.replace(/([^/])$/, "$1/"),
54
- "urlOrigin": !doUseExternalAssets ? undefined : (() => {
55
-
56
- if (url === undefined) {
57
- console.error("ERROR: You must specify 'homepage' in your package.json");
58
- process.exit(-1);
59
- }
60
-
61
- return url.origin;
62
-
63
- })()
64
-
48
+ "urlPathname": url === undefined ? "/" : url.pathname.replace(/([^/])$/, "$1/"),
49
+ "urlOrigin": !doUseExternalAssets
50
+ ? undefined
51
+ : (() => {
52
+ if (url === undefined) {
53
+ console.error("ERROR: You must specify 'homepage' in your package.json");
54
+ process.exit(-1);
55
+ }
56
+
57
+ return url.origin;
58
+ })(),
65
59
  };
66
-
67
60
  })(),
68
61
  extraPagesId,
69
62
  extraThemeProperties,
70
- //We have to leave it at that otherwise we break our default theme.
63
+ //We have to leave it at that otherwise we break our default theme.
71
64
  //Problem is that we can't guarantee that the the old resources common
72
- //will still be available on the newer keycloak version.
73
- "keycloakVersion": "11.0.3"
65
+ //will still be available on the newer keycloak version.
66
+ "keycloakVersion": "11.0.3",
74
67
  });
75
68
 
76
69
  const { jarFilePath } = generateJavaStackFiles({
77
70
  version: parsedPackageJson.version,
78
71
  themeName,
79
72
  homepage: parsedPackageJson.homepage,
80
- keycloakThemeBuildingDirPath
73
+ keycloakThemeBuildingDirPath,
81
74
  });
82
75
 
83
- child_process.execSync(
84
- "mvn package",
85
- { "cwd": keycloakThemeBuildingDirPath }
86
- );
76
+ child_process.execSync("mvn package", {
77
+ "cwd": keycloakThemeBuildingDirPath,
78
+ });
87
79
 
88
80
  generateDebugFiles({
89
81
  keycloakThemeBuildingDirPath,
90
82
  themeName,
91
- "keycloakVersion": "15.0.2"
83
+ "keycloakVersion": "15.0.2",
92
84
  });
93
85
 
94
- console.log([
95
- '',
96
- `✅ Your keycloak theme has been generated and bundled into ./${pathRelative(reactProjectDirPath, jarFilePath)} 🚀`,
97
- `It is to be placed in "/opt/jboss/keycloak/standalone/deployments" in the container running a jboss/keycloak Docker image.`,
98
- '',
99
- 'Using Helm (https://github.com/codecentric/helm-charts), edit to reflect:',
100
- '',
101
- 'value.yaml: ',
102
- ' extraInitContainers: |',
103
- ' - name: realm-ext-provider',
104
- ' image: curlimages/curl',
105
- ' imagePullPolicy: IfNotPresent',
106
- ' command:',
107
- ' - sh',
108
- ' args:',
109
- ' - -c',
110
- ` - curl -L -f -S -o /extensions/${pathBasename(jarFilePath)} https://AN.URL.FOR/${pathBasename(jarFilePath)}`,
111
- ' volumeMounts:',
112
- ' - name: extensions',
113
- ' mountPath: /extensions',
114
- ' ',
115
- ' extraVolumeMounts: |',
116
- ' - name: extensions',
117
- ' mountPath: /opt/jboss/keycloak/standalone/deployments',
118
- ' extraEnv: |',
119
- ' - name: KEYCLOAK_USER',
120
- ' value: admin',
121
- ' - name: KEYCLOAK_PASSWORD',
122
- ' value: xxxxxxxxx',
123
- ' - name: JAVA_OPTS',
124
- ' value: -Dkeycloak.profile=preview',
125
- '',
126
- '',
127
- 'To test your theme locally, with hot reloading, you can spin up a Keycloak container image with the theme loaded by running:',
128
- '',
129
- `👉 $ ./${pathRelative(reactProjectDirPath, pathJoin(keycloakThemeBuildingDirPath, containerLaunchScriptBasename))} 👈`,
130
- '',
131
- 'To enable the theme within keycloak log into the admin console ( 👉 http://localhost:8080 username: admin, password: admin 👈), create a realm (called "myrealm" for example),',
132
- `go to your realm settings, click on the theme tab then select ${themeName}.`,
133
- `More details: https://www.keycloak.org/getting-started/getting-started-docker`,
134
- '',
135
- 'Once your container is up and configured 👉 http://localhost:8080/auth/realms/myrealm/account 👈',
136
- '',
137
- ].join("\n"));
138
-
86
+ console.log(
87
+ [
88
+ "",
89
+ `✅ Your keycloak theme has been generated and bundled into ./${pathRelative(reactProjectDirPath, jarFilePath)} 🚀`,
90
+ `It is to be placed in "/opt/jboss/keycloak/standalone/deployments" in the container running a jboss/keycloak Docker image.`,
91
+ "",
92
+ "Using Helm (https://github.com/codecentric/helm-charts), edit to reflect:",
93
+ "",
94
+ "value.yaml: ",
95
+ " extraInitContainers: |",
96
+ " - name: realm-ext-provider",
97
+ " image: curlimages/curl",
98
+ " imagePullPolicy: IfNotPresent",
99
+ " command:",
100
+ " - sh",
101
+ " args:",
102
+ " - -c",
103
+ ` - curl -L -f -S -o /extensions/${pathBasename(jarFilePath)} https://AN.URL.FOR/${pathBasename(jarFilePath)}`,
104
+ " volumeMounts:",
105
+ " - name: extensions",
106
+ " mountPath: /extensions",
107
+ " ",
108
+ " extraVolumeMounts: |",
109
+ " - name: extensions",
110
+ " mountPath: /opt/jboss/keycloak/standalone/deployments",
111
+ " extraEnv: |",
112
+ " - name: KEYCLOAK_USER",
113
+ " value: admin",
114
+ " - name: KEYCLOAK_PASSWORD",
115
+ " value: xxxxxxxxx",
116
+ " - name: JAVA_OPTS",
117
+ " value: -Dkeycloak.profile=preview",
118
+ "",
119
+ "",
120
+ "To test your theme locally, with hot reloading, you can spin up a Keycloak container image with the theme loaded by running:",
121
+ "",
122
+ `👉 $ ./${pathRelative(reactProjectDirPath, pathJoin(keycloakThemeBuildingDirPath, containerLaunchScriptBasename))} 👈`,
123
+ "",
124
+ 'To enable the theme within keycloak log into the admin console ( 👉 http://localhost:8080 username: admin, password: admin 👈), create a realm (called "myrealm" for example),',
125
+ `go to your realm settings, click on the theme tab then select ${themeName}.`,
126
+ `More details: https://www.keycloak.org/getting-started/getting-started-docker`,
127
+ "",
128
+ "Once your container is up and configured 👉 http://localhost:8080/auth/realms/myrealm/account 👈",
129
+ "",
130
+ ].join("\n"),
131
+ );
139
132
  }
@@ -1,2 +1 @@
1
-
2
- export const ftlValuesGlobalName = "kcContext";
1
+ export const ftlValuesGlobalName = "kcContext";
@@ -1,18 +1,10 @@
1
-
2
1
  import * as fs from "fs";
3
- import { join as pathJoin, dirname as pathDirname, } from "path";
2
+ import { join as pathJoin, dirname as pathDirname } from "path";
4
3
 
5
4
  export const containerLaunchScriptBasename = "start_keycloak_testing_container.sh";
6
5
 
7
6
  /** Files for being able to run a hot reload keycloak container */
8
- export function generateDebugFiles(
9
- params: {
10
- keycloakVersion: "11.0.3" | "15.0.2";
11
- themeName: string;
12
- keycloakThemeBuildingDirPath: string;
13
- }
14
- ) {
15
-
7
+ export function generateDebugFiles(params: { keycloakVersion: "11.0.3" | "15.0.2"; themeName: string; keycloakThemeBuildingDirPath: string }) {
16
8
  const { themeName, keycloakThemeBuildingDirPath, keycloakVersion } = params;
17
9
 
18
10
  fs.writeFileSync(
@@ -29,8 +21,8 @@ export function generateDebugFiles(
29
21
  "",
30
22
  'ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ]',
31
23
  ].join("\n"),
32
- "utf8"
33
- )
24
+ "utf8",
25
+ ),
34
26
  );
35
27
 
36
28
  const dockerImage = `${themeName}/keycloak-hot-reload`;
@@ -54,42 +46,39 @@ export function generateDebugFiles(
54
46
  " -e KEYCLOAK_USER=admin \\",
55
47
  " -e KEYCLOAK_PASSWORD=admin \\",
56
48
  " -e JAVA_OPTS=-Dkeycloak.profile=preview \\",
57
- ` -v ${pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName)
58
- }:/opt/jboss/keycloak/themes/${themeName}:rw \\`,
49
+ ` -v ${pathJoin(
50
+ keycloakThemeBuildingDirPath,
51
+ "src",
52
+ "main",
53
+ "resources",
54
+ "theme",
55
+ themeName,
56
+ )}:/opt/jboss/keycloak/themes/${themeName}:rw \\`,
59
57
  ` -it ${dockerImage}:latest`,
60
- ""
58
+ "",
61
59
  ].join("\n"),
62
- "utf8"
60
+ "utf8",
63
61
  ),
64
- { "mode": 0o755 }
62
+ { "mode": 0o755 },
65
63
  );
66
64
 
67
65
  const standaloneHaFilePath = pathJoin(keycloakThemeBuildingDirPath, "configuration", `standalone-ha.xml`);
68
66
 
69
- try { fs.mkdirSync(pathDirname(standaloneHaFilePath)); } catch { }
67
+ try {
68
+ fs.mkdirSync(pathDirname(standaloneHaFilePath));
69
+ } catch {}
70
70
 
71
71
  fs.writeFileSync(
72
72
  standaloneHaFilePath,
73
- fs.readFileSync(
74
- pathJoin(
75
- __dirname,
76
- `standalone-ha_${keycloakVersion}.xml`
77
- )
78
- )
73
+ fs
74
+ .readFileSync(pathJoin(__dirname, `standalone-ha_${keycloakVersion}.xml`))
79
75
  .toString("utf8")
80
76
  .replace(
81
- new RegExp([
82
- "<staticMaxAge>2592000</staticMaxAge>",
83
- "<cacheThemes>true</cacheThemes>",
84
- "<cacheTemplates>true</cacheTemplates>"
85
- ].join("\\s*"), "g"
77
+ new RegExp(
78
+ ["<staticMaxAge>2592000</staticMaxAge>", "<cacheThemes>true</cacheThemes>", "<cacheTemplates>true</cacheTemplates>"].join("\\s*"),
79
+ "g",
86
80
  ),
87
- [
88
- "<staticMaxAge>-1</staticMaxAge>",
89
- "<cacheThemes>false</cacheThemes>",
90
- "<cacheTemplates>false</cacheTemplates>"
91
- ].join("\n")
92
- )
81
+ ["<staticMaxAge>-1</staticMaxAge>", "<cacheThemes>false</cacheThemes>", "<cacheTemplates>false</cacheTemplates>"].join("\n"),
82
+ ),
93
83
  );
94
-
95
- }
84
+ }
@@ -1 +1 @@
1
- export * from "./generateDebugFiles";
1
+ export * from "./generateDebugFiles";
@@ -126,68 +126,83 @@
126
126
 
127
127
  (()=>{
128
128
 
129
- //Removing all the undefined
130
- const obj = JSON.parse(JSON.stringify(<@objectToJson object=.data_model depth=0 />));
129
+ const nonAutomaticallyConvertible = {
130
+ "messagesPerField": {
131
131
 
132
- //Freemarker values that can't be automatically converted into a JavaScript object.
133
- Object.deepAssign(
134
- obj,
135
- {
136
- "messagesPerField": {
137
- "printIfExists": function (key, x) {
138
- switch(key){
139
- case "userLabel": return (function (){
140
- <#attempt>
141
- return "${messagesPerField.printIfExists('userLabel','1')}" ? x : undefined;
142
- <#recover>
143
- </#attempt>
144
- })();
145
- case "username": return (function (){
146
- <#attempt>
147
- return "${messagesPerField.printIfExists('username','1')}" ? x : undefined;
148
- <#recover>
149
- </#attempt>
150
- })();
151
- case "email": return (function (){
152
- <#attempt>
153
- return "${messagesPerField.printIfExists('email','1')}" ? x : undefined;
154
- <#recover>
155
- </#attempt>
156
- })();
157
- case "firstName": return (function (){
158
- <#attempt>
159
- return "${messagesPerField.printIfExists('firstName','1')}" ? x : undefined;
160
- <#recover>
161
- </#attempt>
162
- })();
163
- case "lastName": return (function (){
164
- <#attempt>
165
- return "${messagesPerField.printIfExists('lastName','1')}" ? x : undefined;
166
- <#recover>
167
- </#attempt>
168
- })();
169
- case "password": return (function (){
170
- <#attempt>
171
- return "${messagesPerField.printIfExists('password','1')}" ? x : undefined;
172
- <#recover>
173
- </#attempt>
174
- })();
175
- case "password-confirm": return (function (){
176
- <#attempt>
177
- return "${messagesPerField.printIfExists('password-confirm','1')}" ? x : undefined;
178
- <#recover>
179
- </#attempt>
180
- })();
132
+ <#assign fieldNames = ["global", "userLabel", "username", "email", "firstName", "lastName", "password", "password-confirm"]>
133
+
134
+ <#attempt>
135
+ <#list profile.attributes as attribute>
136
+ <#assign fieldNames += [attribute.name]>
137
+ </#list>
138
+ <#recover>
139
+ </#attempt>
140
+
141
+ "printIfExists": function (fieldName, x) {
142
+ <#list fieldNames as fieldName>
143
+ if(fieldName === "${fieldName}" ){
144
+ <#attempt>
145
+ return "${messagesPerField.printIfExists(fieldName,'1')}" ? x : undefined;
146
+ <#recover>
147
+ </#attempt>
148
+ }
149
+ </#list>
150
+ throw new Error("There is no " + fieldName + " field");
151
+ },
152
+ "existsError": function (fieldName) {
153
+ <#list fieldNames as fieldName>
154
+ if(fieldName === "${fieldName}" ){
155
+ <#attempt>
156
+ return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>;
157
+ <#recover>
158
+ </#attempt>
159
+ }
160
+ </#list>
161
+ throw new Error("There is no " + fieldName + " field");
162
+ },
163
+ "get": function (fieldName) {
164
+ <#list fieldNames as fieldName>
165
+ if(fieldName === "${fieldName}" ){
166
+ <#attempt>
167
+ <#if messagesPerField.existsError('${fieldName}')>
168
+ return "${messagesPerField.get('${fieldName}')?no_esc}";
169
+ </#if>
170
+ <#recover>
171
+ </#attempt>
181
172
  }
182
- }
173
+ </#list>
174
+ throw new Error("There is no " + fieldName + " field");
183
175
  },
184
- "msg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
185
- "advancedMsg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
186
- }
176
+ "exists": function (fieldName) {
177
+ <#list fieldNames as fieldName>
178
+ if(fieldName === "${fieldName}" ){
179
+ <#attempt>
180
+ return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>;
181
+ <#recover>
182
+ </#attempt>
183
+ }
184
+ </#list>
185
+ throw new Error("There is no " + fieldName + " field");
186
+ }
187
+ },
188
+ "msg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
189
+ "advancedMsg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); }
190
+ };
191
+
192
+ const out = {};
193
+
194
+ Object.deepAssign(
195
+ out,
196
+ //Removing all the undefined
197
+ JSON.parse(JSON.stringify(<@objectToJson object=.data_model depth=0 />))
187
198
  );
188
199
 
189
- return obj;
200
+ Object.deepAssign(
201
+ out,
202
+ nonAutomaticallyConvertible
203
+ );
190
204
 
191
- })()
205
+ return out;
192
206
 
207
+ })()
193
208
  </script>