Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
2f16a09ab8 | |||
183ae98c30 | |||
ba15e63879 | |||
654277feda | |||
81279a5cc5 | |||
59f0a843b0 | |||
c094f70171 | |||
0858fe6319 |
@ -1,3 +1,11 @@
|
|||||||
|
### **0.3.19** (2021-04-01)
|
||||||
|
|
||||||
|
- Fix previous release
|
||||||
|
|
||||||
|
### **0.3.18** (2021-04-01)
|
||||||
|
|
||||||
|
- Fix error.ftt, Adopt best effort strategy to convert ftl values into JS
|
||||||
|
|
||||||
### **0.3.17** (2021-03-29)
|
### **0.3.17** (2021-03-29)
|
||||||
|
|
||||||
- Use push instead of replace in keycloak-js adapter to enable going back
|
- Use push instead of replace in keycloak-js adapter to enable going back
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "keycloakify",
|
"name": "keycloakify",
|
||||||
"version": "0.3.17",
|
"version": "0.3.19",
|
||||||
"description": "Keycloak theme generator for Reacts app",
|
"description": "Keycloak theme generator for Reacts app",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
<script>const _=
|
<script>const _=
|
||||||
{
|
{
|
||||||
"url": {
|
"url": (function (){
|
||||||
"loginAction": "${url.loginAction?no_esc}",
|
|
||||||
"resourcesPath": "${url.resourcesPath?no_esc}",
|
<#if url?has_content>
|
||||||
"resourcesCommonPath": "${url.resourcesCommonPath?no_esc}",
|
|
||||||
"loginRestartFlowUrl": "${url.loginRestartFlowUrl?no_esc}",
|
return {
|
||||||
"loginUrl": "${url.loginUrl?no_esc}"
|
"loginAction": "${(url.loginAction!'')?no_esc}",
|
||||||
},
|
"resourcesPath": "${(url.resourcesPath!'')?no_esc}",
|
||||||
|
"resourcesCommonPath": "${(url.resourcesCommonPath!'')?no_esc}",
|
||||||
|
"loginRestartFlowUrl": "${(url.loginRestartFlowUrl!'')?no_esc}",
|
||||||
|
"loginUrl": "${(url.loginUrl!'')?no_esc}"
|
||||||
|
};
|
||||||
|
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
|
||||||
|
})(),
|
||||||
"realm": {
|
"realm": {
|
||||||
"displayName": "${realm.displayName!''}" || undefined,
|
"displayName": "${realm.displayName!''}" || undefined,
|
||||||
"displayNameHtml": "${realm.displayNameHtml!''}" || undefined,
|
"displayNameHtml": "${realm.displayNameHtml!''}" || undefined,
|
||||||
"internationalizationEnabled": ${realm.internationalizationEnabled?c},
|
"internationalizationEnabled": ${(realm.internationalizationEnabled!false)?c},
|
||||||
"registrationEmailAsUsername": ${realm.registrationEmailAsUsername?c},
|
"registrationEmailAsUsername": ${(realm.registrationEmailAsUsername!false)?c},
|
||||||
},
|
},
|
||||||
"locale": (function (){
|
"locale": (function (){
|
||||||
|
|
||||||
@ -20,23 +30,17 @@
|
|||||||
return {
|
return {
|
||||||
"supported": (function(){
|
"supported": (function(){
|
||||||
|
|
||||||
<#if realm.internationalizationEnabled>
|
var out= [];
|
||||||
|
|
||||||
var out= [];
|
<#list locale.supported as lng>
|
||||||
|
out.push({
|
||||||
|
"url": "${lng.url?no_esc}",
|
||||||
|
"label": "${lng.label}",
|
||||||
|
"languageTag": "${lng.languageTag}"
|
||||||
|
});
|
||||||
|
</#list>
|
||||||
|
|
||||||
<#list locale.supported as lng>
|
return out;
|
||||||
out.push({
|
|
||||||
"url": "${lng.url?no_esc}",
|
|
||||||
"label": "${lng.label}",
|
|
||||||
"languageTag": "${lng.languageTag}"
|
|
||||||
});
|
|
||||||
</#list>
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
|
|
||||||
})(),
|
})(),
|
||||||
"current": "${locale.current}"
|
"current": "${locale.current}"
|
||||||
@ -46,10 +50,10 @@
|
|||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
|
|
||||||
})(),
|
})(),
|
||||||
"auth": (function (){
|
"auth": (function (){
|
||||||
|
|
||||||
|
|
||||||
<#if auth?has_content>
|
<#if auth?has_content>
|
||||||
|
|
||||||
var out= {
|
var out= {
|
||||||
@ -71,9 +75,9 @@
|
|||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
|
|
||||||
})(),
|
})(),
|
||||||
"scripts": (function(){
|
"scripts": (function(){
|
||||||
|
|
@ -19,7 +19,7 @@ function loadAdjacentFile(fileBasename: string) {
|
|||||||
.toString("utf8");
|
.toString("utf8");
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadFtlFile(ftlFileBasename: PageId | "template.ftl") {
|
function loadFtlFile(ftlFileBasename: PageId | "common.ftl") {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
return loadAdjacentFile(ftlFileBasename)
|
return loadAdjacentFile(ftlFileBasename)
|
||||||
@ -91,7 +91,7 @@ export function generateFtlFilesCodeFactory(
|
|||||||
|
|
||||||
//FTL is no valid html, we can't insert with cheerio, we put placeholder for injecting later.
|
//FTL is no valid html, we can't insert with cheerio, we put placeholder for injecting later.
|
||||||
const ftlCommonPlaceholders = {
|
const ftlCommonPlaceholders = {
|
||||||
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }': loadFtlFile("template.ftl"),
|
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }': loadFtlFile("common.ftl"),
|
||||||
'<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->':
|
'<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->':
|
||||||
[
|
[
|
||||||
'<#if scripts??>',
|
'<#if scripts??>',
|
||||||
|
@ -25,7 +25,7 @@ export type TemplateProps = {
|
|||||||
showUsernameNode?: ReactNode;
|
showUsernameNode?: ReactNode;
|
||||||
formNode: ReactNode;
|
formNode: ReactNode;
|
||||||
infoNode?: ReactNode;
|
infoNode?: ReactNode;
|
||||||
} & { kcContext: KcContext.Template; } & KcTemplateProps;
|
} & { kcContext: KcContext; } & KcTemplateProps;
|
||||||
|
|
||||||
export const Template = memo((props: TemplateProps) => {
|
export const Template = memo((props: TemplateProps) => {
|
||||||
|
|
||||||
|
@ -10,12 +10,17 @@ import type { LanguageLabel } from "./i18n/KcLanguageTag";
|
|||||||
type ExtractAfterStartingWith<Prefix extends string, StrEnum> =
|
type ExtractAfterStartingWith<Prefix extends string, StrEnum> =
|
||||||
StrEnum extends `${Prefix}${infer U}` ? U : never;
|
StrEnum extends `${Prefix}${infer U}` ? U : never;
|
||||||
|
|
||||||
|
/** Take theses type definition with a grain of salt.
|
||||||
|
* Some values might be undefined on some pages.
|
||||||
|
* (ex: url.loginAction is undefined on error.ftl)
|
||||||
|
*/
|
||||||
export type KcContext =
|
export type KcContext =
|
||||||
KcContext.Login | KcContext.Register | KcContext.Info |
|
KcContext.Login | KcContext.Register | KcContext.Info |
|
||||||
KcContext.Error | KcContext.LoginResetPassword | KcContext.LoginVerifyEmail;
|
KcContext.Error | KcContext.LoginResetPassword | KcContext.LoginVerifyEmail;
|
||||||
|
|
||||||
export declare namespace KcContext {
|
export declare namespace KcContext {
|
||||||
|
|
||||||
export type Template = {
|
export type Common = {
|
||||||
url: {
|
url: {
|
||||||
loginAction: string;
|
loginAction: string;
|
||||||
resourcesPath: string;
|
resourcesPath: string;
|
||||||
@ -27,7 +32,7 @@ export declare namespace KcContext {
|
|||||||
displayName?: string;
|
displayName?: string;
|
||||||
displayNameHtml?: string;
|
displayNameHtml?: string;
|
||||||
internationalizationEnabled: boolean;
|
internationalizationEnabled: boolean;
|
||||||
registrationEmailAsUsername: boolean; //<---
|
registrationEmailAsUsername: boolean;
|
||||||
};
|
};
|
||||||
/** Undefined if !realm.internationalizationEnabled */
|
/** Undefined if !realm.internationalizationEnabled */
|
||||||
locale?: {
|
locale?: {
|
||||||
@ -55,7 +60,7 @@ export declare namespace KcContext {
|
|||||||
isAppInitiatedAction: boolean;
|
isAppInitiatedAction: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Login = Template & {
|
export type Login = Common & {
|
||||||
pageId: "login.ftl";
|
pageId: "login.ftl";
|
||||||
url: {
|
url: {
|
||||||
loginResetCredentialsUrl: string;
|
loginResetCredentialsUrl: string;
|
||||||
@ -88,7 +93,7 @@ export declare namespace KcContext {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Register = Template & {
|
export type Register = Common & {
|
||||||
pageId: "register.ftl";
|
pageId: "register.ftl";
|
||||||
url: {
|
url: {
|
||||||
registrationAction: string;
|
registrationAction: string;
|
||||||
@ -120,7 +125,7 @@ export declare namespace KcContext {
|
|||||||
recaptchaSiteKey?: string;
|
recaptchaSiteKey?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Info = Template & {
|
export type Info = Common & {
|
||||||
pageId: "info.ftl";
|
pageId: "info.ftl";
|
||||||
messageHeader?: string;
|
messageHeader?: string;
|
||||||
requiredActions?: ExtractAfterStartingWith<"requiredAction.", MessageKey>[];
|
requiredActions?: ExtractAfterStartingWith<"requiredAction.", MessageKey>[];
|
||||||
@ -132,21 +137,21 @@ export declare namespace KcContext {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Error = Template & {
|
export type Error = Common & {
|
||||||
pageId: "error.ftl";
|
pageId: "error.ftl";
|
||||||
client?: {
|
client?: {
|
||||||
baseUrl?: string;
|
baseUrl?: string;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LoginResetPassword = Template & {
|
export type LoginResetPassword = Common & {
|
||||||
pageId: "login-reset-password.ftl";
|
pageId: "login-reset-password.ftl";
|
||||||
realm: {
|
realm: {
|
||||||
loginWithEmailAllowed: boolean;
|
loginWithEmailAllowed: boolean;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LoginVerifyEmail = Template & {
|
export type LoginVerifyEmail = Common & {
|
||||||
pageId: "login-verify-email.ftl";
|
pageId: "login-verify-email.ftl";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { getKcLanguageTagLabel } from "../i18n/KcLanguageTag";
|
|||||||
//NOTE: Aside because we want to be able to import them from node
|
//NOTE: Aside because we want to be able to import them from node
|
||||||
import { resourcesCommonPath, resourcesPath } from "./urlResourcesPath";
|
import { resourcesCommonPath, resourcesPath } from "./urlResourcesPath";
|
||||||
|
|
||||||
export const kcTemplateContext: KcContext.Template = {
|
const kcCommonContext: KcContext.Common = {
|
||||||
"url": {
|
"url": {
|
||||||
"loginAction": "#",
|
"loginAction": "#",
|
||||||
"resourcesPath": `${process.env["PUBLIC_URL"]}/${resourcesPath}`,
|
"resourcesPath": `${process.env["PUBLIC_URL"]}/${resourcesPath}`,
|
||||||
@ -111,7 +111,7 @@ export const kcTemplateContext: KcContext.Template = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
kcTemplateContext.locale!,
|
kcCommonContext.locale!,
|
||||||
"current",
|
"current",
|
||||||
{
|
{
|
||||||
"get": () => getKcLanguageTagLabel(getEvtKcLanguage().state),
|
"get": () => getKcLanguageTagLabel(getEvtKcLanguage().state),
|
||||||
@ -120,22 +120,22 @@ Object.defineProperty(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const kcLoginContext: KcContext.Login = {
|
export const kcLoginContext: KcContext.Login = {
|
||||||
...kcTemplateContext,
|
...kcCommonContext,
|
||||||
"pageId": "login.ftl",
|
"pageId": "login.ftl",
|
||||||
"url": {
|
"url": {
|
||||||
...kcTemplateContext.url,
|
...kcCommonContext.url,
|
||||||
"loginResetCredentialsUrl": "/auth/realms/myrealm/login-actions/reset-credentials?client_id=account&tab_id=HoAx28ja4xg",
|
"loginResetCredentialsUrl": "/auth/realms/myrealm/login-actions/reset-credentials?client_id=account&tab_id=HoAx28ja4xg",
|
||||||
"registrationUrl": "/auth/realms/myrealm/login-actions/registration?client_id=account&tab_id=HoAx28ja4xg"
|
"registrationUrl": "/auth/realms/myrealm/login-actions/registration?client_id=account&tab_id=HoAx28ja4xg"
|
||||||
},
|
},
|
||||||
"realm": {
|
"realm": {
|
||||||
...kcTemplateContext.realm,
|
...kcCommonContext.realm,
|
||||||
"loginWithEmailAllowed": true,
|
"loginWithEmailAllowed": true,
|
||||||
"rememberMe": true,
|
"rememberMe": true,
|
||||||
"password": true,
|
"password": true,
|
||||||
"resetPasswordAllowed": true,
|
"resetPasswordAllowed": true,
|
||||||
"registrationAllowed": true
|
"registrationAllowed": true
|
||||||
},
|
},
|
||||||
"auth": kcTemplateContext.auth!,
|
"auth": kcCommonContext.auth!,
|
||||||
"social": {
|
"social": {
|
||||||
"displayInfo": true
|
"displayInfo": true
|
||||||
},
|
},
|
||||||
@ -147,7 +147,7 @@ export const kcLoginContext: KcContext.Login = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const kcRegisterContext: KcContext.Register = {
|
export const kcRegisterContext: KcContext.Register = {
|
||||||
...kcTemplateContext,
|
...kcCommonContext,
|
||||||
"url": {
|
"url": {
|
||||||
...kcLoginContext.url,
|
...kcLoginContext.url,
|
||||||
"registrationAction": "http://localhost:8080/auth/realms/myrealm/login-actions/registration?session_code=gwZdUeO7pbYpFTRxiIxRg_QtzMbtFTKrNu6XW_f8asM&execution=12146ce0-b139-4bbd-b25b-0eccfee6577e&client_id=account&tab_id=uS8lYfebLa0"
|
"registrationAction": "http://localhost:8080/auth/realms/myrealm/login-actions/registration?session_code=gwZdUeO7pbYpFTRxiIxRg_QtzMbtFTKrNu6XW_f8asM&execution=12146ce0-b139-4bbd-b25b-0eccfee6577e&client_id=account&tab_id=uS8lYfebLa0"
|
||||||
@ -166,7 +166,7 @@ export const kcRegisterContext: KcContext.Register = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const kcInfoContext: KcContext.Info ={
|
export const kcInfoContext: KcContext.Info ={
|
||||||
...kcTemplateContext,
|
...kcCommonContext,
|
||||||
"pageId": "info.ftl",
|
"pageId": "info.ftl",
|
||||||
"messageHeader": "<Message header>",
|
"messageHeader": "<Message header>",
|
||||||
"requiredActions": undefined,
|
"requiredActions": undefined,
|
||||||
@ -178,7 +178,7 @@ export const kcInfoContext: KcContext.Info ={
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const kcErrorContext: KcContext.Error = {
|
export const kcErrorContext: KcContext.Error = {
|
||||||
...kcTemplateContext,
|
...kcCommonContext,
|
||||||
"pageId": "error.ftl",
|
"pageId": "error.ftl",
|
||||||
"client": {
|
"client": {
|
||||||
"baseUrl": "#"
|
"baseUrl": "#"
|
||||||
@ -186,16 +186,16 @@ export const kcErrorContext: KcContext.Error = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const kcLoginResetPasswordContext: KcContext.LoginResetPassword = {
|
export const kcLoginResetPasswordContext: KcContext.LoginResetPassword = {
|
||||||
...kcTemplateContext,
|
...kcCommonContext,
|
||||||
"pageId": "login-reset-password.ftl",
|
"pageId": "login-reset-password.ftl",
|
||||||
"realm":{
|
"realm":{
|
||||||
...kcTemplateContext.realm,
|
...kcCommonContext.realm,
|
||||||
"loginWithEmailAllowed": false
|
"loginWithEmailAllowed": false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const kcLoginVerifyEmailContext: KcContext.LoginVerifyEmail = {
|
export const kcLoginVerifyEmailContext: KcContext.LoginVerifyEmail = {
|
||||||
...kcTemplateContext,
|
...kcCommonContext,
|
||||||
"pageId": "login-verify-email.ftl"
|
"pageId": "login-verify-email.ftl"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user