keycloakify 10.0.0-rc.2 → 10.0.0-rc.3

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 (56) hide show
  1. package/account/Template.js +2 -2
  2. package/account/Template.js.map +1 -1
  3. package/account/i18n/i18n.d.ts +3 -4
  4. package/account/i18n/i18n.js +2 -3
  5. package/account/i18n/i18n.js.map +1 -1
  6. package/account/kcContext/KcContext.d.ts +0 -15
  7. package/account/kcContext/KcContext.js.map +1 -1
  8. package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +160 -243
  9. package/bin/keycloakify/generateFtl/generateFtl.js +1 -1
  10. package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
  11. package/bin/keycloakify/generateStartKeycloakTestingContainer.d.ts +2 -0
  12. package/bin/keycloakify/generateStartKeycloakTestingContainer.js +9 -12
  13. package/bin/keycloakify/generateStartKeycloakTestingContainer.js.map +1 -1
  14. package/bin/keycloakify/keycloakify.js +1 -0
  15. package/bin/keycloakify/keycloakify.js.map +1 -1
  16. package/login/Template.js +2 -2
  17. package/login/Template.js.map +1 -1
  18. package/login/i18n/i18n.d.ts +3 -4
  19. package/login/i18n/i18n.js +2 -3
  20. package/login/i18n/i18n.js.map +1 -1
  21. package/login/pages/Code.js +1 -1
  22. package/login/pages/Code.js.map +1 -1
  23. package/login/pages/IdpReviewUserProfile.js.map +1 -1
  24. package/login/pages/Login.js +1 -1
  25. package/login/pages/Login.js.map +1 -1
  26. package/login/pages/LoginUpdateProfile.js +1 -1
  27. package/login/pages/LoginUpdateProfile.js.map +1 -1
  28. package/login/pages/LoginUsername.js +1 -1
  29. package/login/pages/LoginUsername.js.map +1 -1
  30. package/login/pages/Register.js +1 -1
  31. package/login/pages/Register.js.map +1 -1
  32. package/login/pages/UpdateEmail.js.map +1 -1
  33. package/login/pages/WebauthnRegister.js +1 -1
  34. package/login/pages/WebauthnRegister.js.map +1 -1
  35. package/package.json +1 -7
  36. package/src/account/Template.tsx +2 -5
  37. package/src/account/i18n/i18n.tsx +5 -8
  38. package/src/account/kcContext/KcContext.ts +0 -15
  39. package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +160 -243
  40. package/src/bin/keycloakify/generateFtl/generateFtl.ts +1 -1
  41. package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +13 -14
  42. package/src/bin/keycloakify/keycloakify.ts +1 -0
  43. package/src/login/Template.tsx +6 -22
  44. package/src/login/i18n/i18n.tsx +5 -8
  45. package/src/login/pages/Code.tsx +1 -1
  46. package/src/login/pages/IdpReviewUserProfile.tsx +1 -1
  47. package/src/login/pages/Login.tsx +1 -1
  48. package/src/login/pages/LoginUpdateProfile.tsx +1 -1
  49. package/src/login/pages/LoginUsername.tsx +1 -1
  50. package/src/login/pages/Register.tsx +1 -1
  51. package/src/login/pages/UpdateEmail.tsx +1 -1
  52. package/src/login/pages/WebauthnRegister.tsx +1 -1
  53. package/bin/tools/grant-exec-perms.d.ts +0 -1
  54. package/bin/tools/grant-exec-perms.js +0 -100
  55. package/bin/tools/grant-exec-perms.js.map +0 -1
  56. package/src/bin/tools/grant-exec-perms.ts +0 -19
@@ -32,7 +32,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
32
32
 
33
33
  const { getClassName } = useGetClassName({ doUseDefaultCss, classes });
34
34
 
35
- const { msg, msgStr, changeLocale, labelBySupportedLanguageTag, currentLanguageTag } = i18n;
35
+ const { msg, msgStr, getChangeLocalUrl, labelBySupportedLanguageTag, currentLanguageTag } = i18n;
36
36
 
37
37
  const { realm, locale, auth, url, message, isAppInitiatedAction, authenticationSession, scripts } = kcContext;
38
38
 
@@ -126,31 +126,17 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
126
126
 
127
127
  <div className={getClassName("kcFormCardClass")}>
128
128
  <header className={getClassName("kcFormHeaderClass")}>
129
- {realm.internationalizationEnabled && (assert(locale !== undefined), true) && locale.supported.length > 1 && (
129
+ {realm.internationalizationEnabled && (assert(locale !== undefined), locale.supported.length > 1) && (
130
130
  <div className={getClassName("kcLocaleMainClass")} id="kc-locale">
131
131
  <div id="kc-locale-wrapper" className={getClassName("kcLocaleWrapperClass")}>
132
132
  <div id="kc-locale-dropdown" className={clsx("menu-button-links", getClassName("kcLocaleDropDownClass"))}>
133
133
  {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
134
- <a href="#" id="kc-current-locale-link">
135
- {labelBySupportedLanguageTag[currentLanguageTag]}
136
- </a>
137
- <ul>
138
- {locale.supported.map(({ languageTag }) => (
139
- <li key={languageTag} className="kc-dropdown-item">
140
- {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
141
- <a href="#" onClick={() => changeLocale(languageTag)}>
142
- {labelBySupportedLanguageTag[languageTag]}
143
- </a>
144
- </li>
145
- ))}
146
- </ul>
147
-
148
134
  <button
149
135
  tabIndex={1}
150
136
  id="kc-current-locale-link"
151
137
  aria-label={msgStr("languages" as any)}
152
- aria-haspopup={true}
153
- aria-expanded={false}
138
+ aria-haspopup="true"
139
+ aria-expanded="false"
154
140
  aria-controls="language-switch1"
155
141
  >
156
142
  {labelBySupportedLanguageTag[currentLanguageTag]}
@@ -165,13 +151,11 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
165
151
  >
166
152
  {locale.supported.map(({ languageTag }, i) => (
167
153
  <li key={languageTag} className={getClassName("kcLocaleListItemClass")} role="none">
168
- {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
169
154
  <a
170
155
  role="menuitem"
171
- id={`language-${i}`}
156
+ id={`language-${i + 1}`}
172
157
  className={getClassName("kcLocaleItemClass")}
173
- href="#"
174
- onClick={() => changeLocale(languageTag)}
158
+ href={getChangeLocalUrl(languageTag)}
175
159
  >
176
160
  {labelBySupportedLanguageTag[languageTag]}
177
161
  </a>
@@ -28,11 +28,10 @@ export type GenericI18n<MessageKey extends string> = {
28
28
  */
29
29
  currentLanguageTag: string;
30
30
  /**
31
- * To call when the user switch language.
32
- * This will cause the page to be reloaded,
33
- * on next load currentLanguageTag === newLanguageTag
31
+ * Redirect to this url to change the language.
32
+ * After reload currentLanguageTag === newLanguageTag
34
33
  */
35
- changeLocale: (newLanguageTag: string) => never;
34
+ getChangeLocalUrl: (newLanguageTag: string) => string;
36
35
  /**
37
36
  * e.g. "en" => "English", "fr" => "Français", ...
38
37
  *
@@ -104,7 +103,7 @@ export function createUseI18n<ExtraMessageKey extends string = never>(extraMessa
104
103
  } as any
105
104
  }),
106
105
  currentLanguageTag,
107
- "changeLocale": newLanguageTag => {
106
+ "getChangeLocalUrl": newLanguageTag => {
108
107
  const { locale } = kcContext;
109
108
 
110
109
  assert(locale !== undefined, "Internationalization not enabled");
@@ -113,9 +112,7 @@ export function createUseI18n<ExtraMessageKey extends string = never>(extraMessa
113
112
 
114
113
  assert(targetSupportedLocale !== undefined, `${newLanguageTag} need to be enabled in Keycloak admin`);
115
114
 
116
- window.location.href = targetSupportedLocale.url;
117
-
118
- assert(false, "never");
115
+ return targetSupportedLocale.url;
119
116
  },
120
117
  "labelBySupportedLanguageTag": Object.fromEntries(
121
118
  (kcContext.locale?.supported ?? []).map(({ languageTag, label }) => [languageTag, label])
@@ -24,7 +24,7 @@ export default function Code(props: PageProps<Extract<KcContext, { pageId: "code
24
24
  {code.success ? (
25
25
  <>
26
26
  <p>{msg("copyCodeInstruction")}</p>
27
- <input id="code" className={getClassName("kcTextareaClass")} value={code.code} />
27
+ <input id="code" className={getClassName("kcTextareaClass")} defaultValue={code.code} />
28
28
  </>
29
29
  ) : (
30
30
  <p id="error">{code.error}</p>
@@ -29,7 +29,7 @@ export default function IdpReviewUserProfile(props: IdpReviewUserProfileProps) {
29
29
  <Template
30
30
  {...{ kcContext, i18n, doUseDefaultCss, classes }}
31
31
  displayMessage={messagesPerField.exists("global")}
32
- displayRequiredFields={true}
32
+ displayRequiredFields
33
33
  headerNode={msg("loginIdpReviewProfileTitle")}
34
34
  >
35
35
  <form id="kc-idp-review-profile-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post">
@@ -104,7 +104,7 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
104
104
  id="username"
105
105
  className={getClassName("kcInputClass")}
106
106
  name="username"
107
- value={login.username ?? ""}
107
+ defaultValue={login.username ?? ""}
108
108
  type="text"
109
109
  autoFocus
110
110
  autoComplete="username"
@@ -26,7 +26,7 @@ export default function LoginUpdateProfile(props: LoginUpdateProfileProps) {
26
26
  const [isFormSubmittable, setIsFormSubmittable] = useState(false);
27
27
 
28
28
  return (
29
- <Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("loginProfileTitle")}>
29
+ <Template {...{ kcContext, i18n, doUseDefaultCss, classes }} displayRequiredFields headerNode={msg("loginProfileTitle")}>
30
30
  <form id="kc-update-profile-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post">
31
31
  <UserProfileFormFields
32
32
  {...{
@@ -101,7 +101,7 @@ export default function LoginUsername(props: PageProps<Extract<KcContext, { page
101
101
  id="username"
102
102
  className={getClassName("kcInputClass")}
103
103
  name="username"
104
- value={login.username ?? ""}
104
+ defaultValue={login.username ?? ""}
105
105
  type="text"
106
106
  autoFocus
107
107
  autoComplete="off"
@@ -28,7 +28,7 @@ export default function Register(props: RegisterProps) {
28
28
  const [isFormSubmittable, setIsFormSubmittable] = useState(false);
29
29
 
30
30
  return (
31
- <Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("registerTitle")}>
31
+ <Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("registerTitle")} displayRequiredFields>
32
32
  <form id="kc-register-form" className={getClassName("kcFormClass")} action={url.registrationAction} method="post">
33
33
  <UserProfileFormFields
34
34
  {...{
@@ -29,7 +29,7 @@ export default function UpdateEmail(props: UpdateEmailProps) {
29
29
  <Template
30
30
  {...{ kcContext, i18n, doUseDefaultCss, classes }}
31
31
  displayMessage={messagesPerField.exists("global")}
32
- displayRequiredFields={true}
32
+ displayRequiredFields
33
33
  headerNode={msg("updateEmailTitle")}
34
34
  >
35
35
  <form id="kc-update-email-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post">
@@ -275,7 +275,7 @@ function LogoutOtherSessions(props: { i18n: I18n; getClassName: ReturnType<typeo
275
275
  <div className={getClassName("kcFormOptionsWrapperClass")}>
276
276
  <div className="checkbox">
277
277
  <label>
278
- <input type="checkbox" id="logout-sessions" name="logout-sessions" value="on" checked />
278
+ <input type="checkbox" id="logout-sessions" name="logout-sessions" value="on" defaultChecked={true} />
279
279
  {msg("logoutOtherSessions")}
280
280
  </label>
281
281
  </div>
@@ -1 +0,0 @@
1
- export {};
@@ -1,100 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- var getThisCodebaseRootDirPath_1 = require("./getThisCodebaseRootDirPath");
63
- var path_1 = require("path");
64
- var fs_1 = require("fs");
65
- var promises_1 = require("fs/promises");
66
- (function () { return __awaiter(void 0, void 0, void 0, function () {
67
- var thisCodebaseRootDirPath, bin, promises;
68
- return __generator(this, function (_a) {
69
- var _b;
70
- switch (_a.label) {
71
- case 0:
72
- thisCodebaseRootDirPath = (0, getThisCodebaseRootDirPath_1.getThisCodebaseRootDirPath)();
73
- return [4 /*yield*/, (_b = (0, path_1.join)(thisCodebaseRootDirPath, "package.json"), Promise.resolve().then(function () { return __importStar(require(_b)); }))];
74
- case 1:
75
- bin = (_a.sent()).bin;
76
- promises = Object.values(bin).map(function (scriptPath) { return __awaiter(void 0, void 0, void 0, function () {
77
- var fullPath, oldMode, newMode;
78
- return __generator(this, function (_a) {
79
- switch (_a.label) {
80
- case 0:
81
- fullPath = (0, path_1.join)(thisCodebaseRootDirPath, scriptPath);
82
- return [4 /*yield*/, (0, promises_1.stat)(fullPath)];
83
- case 1:
84
- oldMode = (_a.sent()).mode;
85
- newMode = oldMode | fs_1.constants.S_IXUSR | fs_1.constants.S_IXGRP | fs_1.constants.S_IXOTH;
86
- return [4 /*yield*/, (0, promises_1.chmod)(fullPath, newMode)];
87
- case 2:
88
- _a.sent();
89
- return [2 /*return*/];
90
- }
91
- });
92
- }); });
93
- return [4 /*yield*/, Promise.all(promises)];
94
- case 2:
95
- _a.sent();
96
- return [2 /*return*/];
97
- }
98
- });
99
- }); })();
100
- //# sourceMappingURL=grant-exec-perms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grant-exec-perms.js","sourceRoot":"","sources":["../../src/bin/tools/grant-exec-perms.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA0E;AAC1E,6BAAwC;AACxC,yBAA+B;AAC/B,wCAA0C;AAE1C,CAAC;;;;;;gBACS,uBAAuB,GAAG,IAAA,uDAA0B,GAAE,CAAC;gBAE7C,2BAAa,IAAA,WAAQ,EAAC,uBAAuB,EAAE,cAAc,CAAC,8EAAC;;gBAAvE,GAAG,GAAK,CAAA,SAA+D,CAAA,IAApE;gBAEL,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAS,GAAG,CAAC,CAAC,GAAG,CAAC,UAAM,UAAU;;;;;gCACtD,QAAQ,GAAG,IAAA,WAAQ,EAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;gCAC9C,qBAAM,IAAA,eAAI,EAAC,QAAQ,CAAC,EAAA;;gCAA/B,OAAO,GAAG,CAAC,SAAoB,CAAC,CAAC,IAAI;gCACrC,OAAO,GAAG,OAAO,GAAG,cAAS,CAAC,OAAO,GAAG,cAAS,CAAC,OAAO,GAAG,cAAS,CAAC,OAAO,CAAC;gCACpF,qBAAM,IAAA,gBAAK,EAAC,QAAQ,EAAE,OAAO,CAAC,EAAA;;gCAA9B,SAA8B,CAAC;;;;qBAClC,CAAC,CAAC;gBAEH,qBAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAA;;gBAA3B,SAA2B,CAAC;;;;KAC/B,CAAC,EAAE,CAAC"}
@@ -1,19 +0,0 @@
1
- import { getThisCodebaseRootDirPath } from "./getThisCodebaseRootDirPath";
2
- import { join as pathJoin } from "path";
3
- import { constants } from "fs";
4
- import { chmod, stat } from "fs/promises";
5
-
6
- (async () => {
7
- const thisCodebaseRootDirPath = getThisCodebaseRootDirPath();
8
-
9
- const { bin } = await import(pathJoin(thisCodebaseRootDirPath, "package.json"));
10
-
11
- const promises = Object.values<string>(bin).map(async scriptPath => {
12
- const fullPath = pathJoin(thisCodebaseRootDirPath, scriptPath);
13
- const oldMode = (await stat(fullPath)).mode;
14
- const newMode = oldMode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH;
15
- await chmod(fullPath, newMode);
16
- });
17
-
18
- await Promise.all(promises);
19
- })();