Refactor of the FreeMarker template
This commit is contained in:
parent
54f43d3331
commit
2754900f7a
@ -24,6 +24,7 @@ export type BuildContextLike = BuildContextLike_generatePom & {
|
|||||||
artifactId: string;
|
artifactId: string;
|
||||||
themeVersion: string;
|
themeVersion: string;
|
||||||
cacheDirPath: string;
|
cacheDirPath: string;
|
||||||
|
recordIsImplementedByThemeType: BuildContext["recordIsImplementedByThemeType"];
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildContext extends BuildContextLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
@ -134,6 +135,10 @@ export async function buildJar(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
route_legacy_pages: {
|
route_legacy_pages: {
|
||||||
|
if (!buildContext.recordIsImplementedByThemeType.login) {
|
||||||
|
break route_legacy_pages;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: If there's no account theme there is no special target for keycloak 24 and up so we create
|
// NOTE: If there's no account theme there is no special target for keycloak 24 and up so we create
|
||||||
// the pages anyway. If there is an account pages, since we know that account-v1 is only support keycloak
|
// the pages anyway. If there is an account pages, since we know that account-v1 is only support keycloak
|
||||||
// 24 in version 0.4 and up, we can safely break the route for legacy pages.
|
// 24 in version 0.4 and up, we can safely break the route for legacy pages.
|
||||||
@ -165,7 +170,7 @@ export async function buildJar(params: {
|
|||||||
|
|
||||||
const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
|
const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
|
||||||
|
|
||||||
const realPageId = (() => {
|
const ftlFileBasename = (() => {
|
||||||
switch (pageId) {
|
switch (pageId) {
|
||||||
case "register.ftl":
|
case "register.ftl":
|
||||||
return "register-user-profile.ftl";
|
return "register-user-profile.ftl";
|
||||||
@ -176,14 +181,14 @@ export async function buildJar(params: {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
const modifiedFtlFileContent = ftlFileContent.replace(
|
const modifiedFtlFileContent = ftlFileContent.replace(
|
||||||
`kcContext.pageId = "\${pageId}";`,
|
`"ftlTemplateFileName": "${pageId}"`,
|
||||||
`kcContext.pageId = "${pageId}"; kcContext.realPageId = "${realPageId}";`
|
`"ftlTemplateFileName": "${ftlFileBasename}"`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(modifiedFtlFileContent !== ftlFileContent);
|
assert(modifiedFtlFileContent !== ftlFileContent);
|
||||||
|
|
||||||
fs.writeFile(
|
fs.writeFile(
|
||||||
pathJoin(pathDirname(ftlFilePath), realPageId),
|
pathJoin(pathDirname(ftlFilePath), ftlFileBasename),
|
||||||
Buffer.from(modifiedFtlFileContent, "utf8")
|
Buffer.from(modifiedFtlFileContent, "utf8")
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
@ -34,7 +34,6 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
keycloakifyVersion: string;
|
keycloakifyVersion: string;
|
||||||
themeType: ThemeType;
|
themeType: ThemeType;
|
||||||
fieldNames: string[];
|
fieldNames: string[];
|
||||||
isAccountV3: boolean;
|
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
themeName,
|
themeName,
|
||||||
@ -42,8 +41,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
buildContext,
|
buildContext,
|
||||||
keycloakifyVersion,
|
keycloakifyVersion,
|
||||||
themeType,
|
themeType,
|
||||||
fieldNames,
|
fieldNames
|
||||||
isAccountV3
|
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const $ = cheerio.load(indexHtmlCode);
|
const $ = cheerio.load(indexHtmlCode);
|
||||||
@ -70,8 +68,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
const { fixedCssCode } = replaceImportsInCssCode({
|
const { fixedCssCode } = replaceImportsInCssCode({
|
||||||
cssCode,
|
cssCode,
|
||||||
cssFileRelativeDirPath: undefined,
|
cssFileRelativeDirPath: undefined,
|
||||||
buildContext,
|
buildContext
|
||||||
isAccountV3
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(element).text(fixedCssCode);
|
$(element).text(fixedCssCode);
|
||||||
@ -96,7 +93,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
new RegExp(
|
new RegExp(
|
||||||
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
||||||
),
|
),
|
||||||
`\${${!isAccountV3 ? "url.resourcesPath" : "resourceUrl"}}/${basenameOfTheKeycloakifyResourcesDir}/`
|
`\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -116,19 +113,17 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.toString("utf8")
|
.toString("utf8")
|
||||||
|
.replace("{{themeType}}", themeType)
|
||||||
|
.replace("{{themeName}}", themeName)
|
||||||
|
.replace("{{keycloakifyVersion}}", keycloakifyVersion)
|
||||||
|
.replace("{{themeVersion}}", buildContext.themeVersion)
|
||||||
|
.replace("{{fieldNames}}", fieldNames.map(name => `"${name}"`).join(", "))
|
||||||
|
.replace("{{RESOURCES_COMMON}}", resources_common)
|
||||||
.replace(
|
.replace(
|
||||||
"FIELD_NAMES_eKsIY4ZsZ4xeM",
|
"{{userDefinedExclusions}}",
|
||||||
fieldNames.map(name => `"${name}"`).join(", ")
|
|
||||||
)
|
|
||||||
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion)
|
|
||||||
.replace("KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx", buildContext.themeVersion)
|
|
||||||
.replace("KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr", themeType)
|
|
||||||
.replace("KEYCLOAKIFY_THEME_NAME_cXxKd3xEer", themeName)
|
|
||||||
.replace("RESOURCES_COMMON_cLsLsMrtDkpVv", resources_common)
|
|
||||||
.replace(
|
|
||||||
"USER_DEFINED_EXCLUSIONS_eKsaY4ZsZ4eMr2",
|
|
||||||
buildContext.kcContextExclusionsFtlCode ?? ""
|
buildContext.kcContextExclusionsFtlCode ?? ""
|
||||||
);
|
);
|
||||||
|
|
||||||
const ftlObjectToJsCodeDeclaringAnObjectPlaceholder =
|
const ftlObjectToJsCodeDeclaringAnObjectPlaceholder =
|
||||||
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
|
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
|
||||||
|
|
||||||
@ -173,7 +168,8 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
Object.entries({
|
Object.entries({
|
||||||
[ftlObjectToJsCodeDeclaringAnObjectPlaceholder]:
|
[ftlObjectToJsCodeDeclaringAnObjectPlaceholder]:
|
||||||
kcContextDeclarationTemplateFtl,
|
kcContextDeclarationTemplateFtl,
|
||||||
PAGE_ID_xIgLsPgGId9D8e: pageId
|
"{{pageId}}": pageId,
|
||||||
|
"{{ftlTemplateFileName}}": pageId
|
||||||
}).map(
|
}).map(
|
||||||
([searchValue, replaceValue]) =>
|
([searchValue, replaceValue]) =>
|
||||||
(ftlCode = ftlCode.replace(searchValue, replaceValue))
|
(ftlCode = ftlCode.replace(searchValue, replaceValue))
|
||||||
|
@ -1,19 +1,48 @@
|
|||||||
<#assign pageId="PAGE_ID_xIgLsPgGId9D8e">
|
<#assign xKeycloakify={
|
||||||
<#assign themeType="KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr">
|
"messages": {},
|
||||||
<#assign xKeycloakifyMessages = {}>
|
"pageId": "{{pageId}}",
|
||||||
|
"ftlTemplateFileName": "{{ftlTemplateFileName}}",
|
||||||
|
"themeType": "{{themeType}}",
|
||||||
|
"themeName": "{{themeName}}",
|
||||||
|
"keycloakifyVersion": "{{keycloakifyVersion}}",
|
||||||
|
"themeVersion": "{{themeVersion}}",
|
||||||
|
"resourcesPath": ""
|
||||||
|
}>
|
||||||
|
|
||||||
const kcContext = ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
|
<#if url?? && url?is_hash && url.resourcesPath?? && url.resourcesPath?is_string>
|
||||||
|
<#assign xKeycloakify = xKeycloakify + { "resourcesPath": url.resourcesPath }>
|
||||||
|
</#if>
|
||||||
|
<#if resourceUrl?? && resourceUrl?is_string>
|
||||||
|
<#assign xKeycloakify = xKeycloakify + { "resourcesPath": resourceUrl }>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
const kcContext = ${toJsDeclarationString(.data_model, [])?no_esc};
|
||||||
|
kcContext.keycloakifyVersion = "${xKeycloakify.keycloakifyVersion}";
|
||||||
|
kcContext.themeVersion = "${xKeycloakify.themeVersion}";
|
||||||
|
kcContext.themeType = "${xKeycloakify.themeType}";
|
||||||
|
kcContext.themeName = "${xKeycloakify.themeName}";
|
||||||
|
kcContext.pageId = "${xKeycloakify.pageId}";
|
||||||
|
kcContext.ftlTemplateFileName = "${xKeycloakify.ftlTemplateFileName}";
|
||||||
|
|
||||||
<@addNonAutomaticallyGatherableMessagesToXKeycloakifyMessages />
|
<@addNonAutomaticallyGatherableMessagesToXKeycloakifyMessages />
|
||||||
|
|
||||||
kcContext["x-keycloakify"] = {};
|
kcContext["x-keycloakify"] = {};
|
||||||
|
|
||||||
|
kcContext["x-keycloakify"].resourcesPath = "${xKeycloakify.resourcesPath}";
|
||||||
|
|
||||||
{
|
{
|
||||||
var messages = {};
|
var messages = {};
|
||||||
<#list xKeycloakifyMessages as key, resolvedMsg>
|
<#list xKeycloakify.messages as key, resolvedMsg>
|
||||||
messages["${key}"] = decodeHtmlEntities("${resolvedMsg?js_string}");
|
messages["${key}"] = decodeHtmlEntities("${resolvedMsg?js_string}");
|
||||||
</#list>
|
</#list>
|
||||||
kcContext["x-keycloakify"].messages = messages;
|
kcContext["x-keycloakify"].messages = messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(
|
||||||
|
kcContext.url instanceof Object &&
|
||||||
|
typeof kcContext.url.resourcesPath === "string"
|
||||||
|
){
|
||||||
|
kcContext.url.resourcesCommonPath = kcContext.url.resourcesPath + "/{{RESOURCES_COMMON}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if( kcContext.messagesPerField ){
|
if( kcContext.messagesPerField ){
|
||||||
@ -41,23 +70,6 @@ if( kcContext.messagesPerField ){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
kcContext.keycloakifyVersion = "KEYCLOAKIFY_VERSION_xEdKd3xEdr";
|
|
||||||
kcContext.themeVersion = "KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx";
|
|
||||||
kcContext.themeType = "${themeType}";
|
|
||||||
kcContext.themeName = "KEYCLOAKIFY_THEME_NAME_cXxKd3xEer";
|
|
||||||
kcContext.pageId = "${pageId}";
|
|
||||||
if( kcContext.url && kcContext.url.resourcesPath ){
|
|
||||||
kcContext.url.resourcesCommonPath = kcContext.url.resourcesPath + "/" + "RESOURCES_COMMON_cLsLsMrtDkpVv";
|
|
||||||
}
|
|
||||||
if( kcContext.resourceUrl && !kcContext.url ){
|
|
||||||
Object.defineProperty(kcContext, "url", {
|
|
||||||
value: {
|
|
||||||
resourcesPath: kcContext.resourceUrl
|
|
||||||
},
|
|
||||||
enumerable: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
attributes_to_attributesByName: {
|
attributes_to_attributesByName: {
|
||||||
if( !kcContext.profile ){
|
if( !kcContext.profile ){
|
||||||
break attributes_to_attributesByName;
|
break attributes_to_attributesByName;
|
||||||
@ -83,451 +95,450 @@ function decodeHtmlEntities(htmlStr){
|
|||||||
return element.value;
|
return element.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
<#function ftl_object_to_js_code_declaring_an_object object path>
|
<#function toJsDeclarationString object path>
|
||||||
|
<#local isHash = -1>
|
||||||
|
<#attempt>
|
||||||
|
<#local isHash = object?is_hash || object?is_hash_ex>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't evaluate if " + path?join(".") + " is a hash">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
|
<#if isHash>
|
||||||
|
<#if path?size gt 10>
|
||||||
|
<#return "ABORT: Too many recursive calls, path: " + path?join(".")>
|
||||||
|
</#if>
|
||||||
|
<#local keys = -1>
|
||||||
|
|
||||||
<#local isHash = "">
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#local isHash = object?is_hash || object?is_hash_ex>
|
<#local keys = object?keys>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#return "ABORT: Can't evaluate if " + path?join(".") + " is hash">
|
<#return "ABORT: We can't list keys on object">
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
<#if isHash>
|
<#local outSeq = []>
|
||||||
|
|
||||||
<#if path?size gt 10>
|
<#list keys as key>
|
||||||
<#return "ABORT: Too many recursive calls, path: " + path?join(".")>
|
<#if ["class","declaredConstructors","superclass","declaringClass" ]?seq_contains(key) >
|
||||||
|
<#continue>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local keys = "">
|
<#if (
|
||||||
|
areSamePath(path, ["url"]) &&
|
||||||
|
["loginUpdatePasswordUrl", "loginUpdateProfileUrl", "loginUsernameReminderUrl", "loginUpdateTotpUrl"]?seq_contains(key)
|
||||||
|
) || (
|
||||||
|
key == "updateProfileCtx" &&
|
||||||
|
areSamePath(path, [])
|
||||||
|
) || (
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/pull/65#issuecomment-991896344 (reports with saml-post-form.ftl) -->
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/issues/91#issue-1212319466 (reports with error.ftl and Kc18) -->
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/issues/109#issuecomment-1134610163 -->
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/issues/357 -->
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/discussions/406#discussioncomment-7514787 -->
|
||||||
|
key == "loginAction" &&
|
||||||
|
areSamePath(path, ["url"]) &&
|
||||||
|
["saml-post-form.ftl", "error.ftl", "info.ftl", "login-oauth-grant.ftl", "logout-confirm.ftl", "login-oauth2-device-verify-user-code.ftl"]?seq_contains(xKeycloakify.pageId) &&
|
||||||
|
!(auth?has_content && auth.showTryAnotherWayLink())
|
||||||
|
) || (
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/issues/362 -->
|
||||||
|
["secretData", "value"]?seq_contains(key) &&
|
||||||
|
areSamePath(path, [ "totp", "otpCredentials", "*" ])
|
||||||
|
) || (
|
||||||
|
["contextData", "idpConfig", "idp", "authenticationSession"]?seq_contains(key) &&
|
||||||
|
areSamePath(path, ["brokerContext"]) &&
|
||||||
|
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(xKeycloakify.pageId)
|
||||||
|
) || (
|
||||||
|
key == "identityProviderBrokerCtx" &&
|
||||||
|
areSamePath(path, []) &&
|
||||||
|
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(xKeycloakify.pageId)
|
||||||
|
) || (
|
||||||
|
["masterAdminClient", "delegateForUpdate", "defaultRole"]?seq_contains(key) &&
|
||||||
|
areSamePath(path, ["realm"])
|
||||||
|
) || (
|
||||||
|
xKeycloakify.pageId == "error.ftl" &&
|
||||||
|
areSamePath(path, ["realm"]) &&
|
||||||
|
!["name", "displayName", "displayNameHtml", "internationalizationEnabled", "registrationEmailAsUsername" ]?seq_contains(key)
|
||||||
|
) || (
|
||||||
|
xKeycloakify.pageId == "applications.ftl" &&
|
||||||
|
(
|
||||||
|
key == "realm" ||
|
||||||
|
key == "container"
|
||||||
|
) &&
|
||||||
|
isSubpath(path, ["applications", "applications"])
|
||||||
|
) || (
|
||||||
|
key == "delegateForUpdate" &&
|
||||||
|
areSamePath(path, ["user"])
|
||||||
|
) || (
|
||||||
|
<#-- Security audit forwarded by Garth (Gmail) -->
|
||||||
|
key == "saml.signing.private.key" &&
|
||||||
|
areSamePath(path, ["client", "attributes"])
|
||||||
|
) || (
|
||||||
|
<#-- See: https://github.com/keycloakify/keycloakify/issues/534 -->
|
||||||
|
key == "password" &&
|
||||||
|
areSamePath(path, ["login"])
|
||||||
|
) || (
|
||||||
|
<#-- Remove realmAttributes added by https://github.com/jcputney/keycloak-theme-additional-info-extension for peace of mind. -->
|
||||||
|
key == "realmAttributes" &&
|
||||||
|
areSamePath(path, [])
|
||||||
|
) || (
|
||||||
|
<#-- attributesByName adds a lot of noise to the output and is not needed, we already have profile.attributes -->
|
||||||
|
key == "attributesByName" &&
|
||||||
|
areSamePath(path, ["profile"])
|
||||||
|
) || (
|
||||||
|
<#-- We already have the attributes in profile speedup the rendering by filtering it out from the register object -->
|
||||||
|
(key == "attributes" || key == "attributesByName") &&
|
||||||
|
areSamePath(path, ["register"])
|
||||||
|
) || (
|
||||||
|
areSamePath(path, ["properties"]) &&
|
||||||
|
(
|
||||||
|
key?starts_with("kc") ||
|
||||||
|
key == "locales" ||
|
||||||
|
key == "import" ||
|
||||||
|
key == "parent" ||
|
||||||
|
key == "meta" ||
|
||||||
|
key == "stylesCommon" ||
|
||||||
|
key == "styles" ||
|
||||||
|
key == "accountResourceProvider"
|
||||||
|
)
|
||||||
|
) || (
|
||||||
|
key == "execution" &&
|
||||||
|
areSamePath(path, [])
|
||||||
|
) || (
|
||||||
|
key == "entity" &&
|
||||||
|
areSamePath(path, ["user"])
|
||||||
|
)
|
||||||
|
>
|
||||||
|
<#-- <#local outSeq += ["/*" + path?join(".") + "." + key + " excluded*/"]> -->
|
||||||
|
<#continue>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#-- https://github.com/keycloakify/keycloakify/discussions/406 -->
|
||||||
|
<#if (
|
||||||
|
key == "attemptedUsername" &&
|
||||||
|
areSamePath(path, ["auth"]) &&
|
||||||
|
[
|
||||||
|
"register.ftl", "terms.ftl", "info.ftl", "login.ftl",
|
||||||
|
"login-update-password.ftl", "login-oauth2-device-verify-user-code.ftl"
|
||||||
|
]?seq_contains(xKeycloakify.pageId)
|
||||||
|
)>
|
||||||
|
<#attempt>
|
||||||
|
<#-- https://github.com/keycloak/keycloak/blob/3a2bf0c04bcde185e497aaa32d0bb7ab7520cf4a/themes/src/main/resources/theme/base/login/template.ftl#L63 -->
|
||||||
|
<#if !(auth?has_content && auth.showUsername() && !auth.showResetCredentials())>
|
||||||
|
<#local outSeq += ["/*" + path?join(".") + "." + key + " excluded*/"]>
|
||||||
|
<#continue>
|
||||||
|
</#if>
|
||||||
|
<#recover>
|
||||||
|
<#local outSeq += ["/*Accessing attemptedUsername throwed an exception */"]>
|
||||||
|
</#attempt>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
{{userDefinedExclusions}}
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#local keys = object?keys>
|
<#if !object[key]??>
|
||||||
|
<#continue>
|
||||||
|
</#if>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#return "ABORT: We can't list keys on this object">
|
<#local outSeq += ["/*Couldn't test if '" + key + "' is available on this object*/"]>
|
||||||
|
<#continue>
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
<#local out_seq = []>
|
<#local propertyValue = -1>
|
||||||
|
|
||||||
<#list keys as key>
|
<#attempt>
|
||||||
|
<#local propertyValue = object[key]>
|
||||||
|
<#recover>
|
||||||
|
<#local outSeq += ["/*Couldn't dereference '" + key + "' on this object*/"]>
|
||||||
|
<#continue>
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
<#if ["class","declaredConstructors","superclass","declaringClass" ]?seq_contains(key) >
|
<#local recOut = toJsDeclarationString(propertyValue, path + [ key ])>
|
||||||
<#continue>
|
|
||||||
|
<#if recOut?starts_with("ABORT:")>
|
||||||
|
|
||||||
|
<#local errorMessage = recOut?remove_beginning("ABORT:")>
|
||||||
|
|
||||||
|
<#if errorMessage != " It's a method" >
|
||||||
|
<#local outSeq += ["/*" + key + ": " + errorMessage + "*/"]>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#if
|
<#continue>
|
||||||
(
|
</#if>
|
||||||
["loginUpdatePasswordUrl", "loginUpdateProfileUrl", "loginUsernameReminderUrl", "loginUpdateTotpUrl"]?seq_contains(key) &&
|
|
||||||
are_same_path(path, ["url"])
|
|
||||||
) || (
|
|
||||||
key == "updateProfileCtx" &&
|
|
||||||
are_same_path(path, [])
|
|
||||||
) || (
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/pull/65#issuecomment-991896344 (reports with saml-post-form.ftl) -->
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/issues/91#issue-1212319466 (reports with error.ftl and Kc18) -->
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/issues/109#issuecomment-1134610163 -->
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/issues/357 -->
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/discussions/406#discussioncomment-7514787 -->
|
|
||||||
key == "loginAction" &&
|
|
||||||
are_same_path(path, ["url"]) &&
|
|
||||||
["saml-post-form.ftl", "error.ftl", "info.ftl", "login-oauth-grant.ftl", "logout-confirm.ftl", "login-oauth2-device-verify-user-code.ftl"]?seq_contains(pageId) &&
|
|
||||||
!(auth?has_content && auth.showTryAnotherWayLink())
|
|
||||||
) || (
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/issues/362 -->
|
|
||||||
["secretData", "value"]?seq_contains(key) &&
|
|
||||||
are_same_path(path, [ "totp", "otpCredentials", "*" ])
|
|
||||||
) || (
|
|
||||||
["contextData", "idpConfig", "idp", "authenticationSession"]?seq_contains(key) &&
|
|
||||||
are_same_path(path, ["brokerContext"]) &&
|
|
||||||
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId)
|
|
||||||
) || (
|
|
||||||
key == "identityProviderBrokerCtx" &&
|
|
||||||
are_same_path(path, []) &&
|
|
||||||
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId)
|
|
||||||
) || (
|
|
||||||
["masterAdminClient", "delegateForUpdate", "defaultRole"]?seq_contains(key) &&
|
|
||||||
are_same_path(path, ["realm"])
|
|
||||||
) || (
|
|
||||||
"error.ftl" == pageId &&
|
|
||||||
are_same_path(path, ["realm"]) &&
|
|
||||||
!["name", "displayName", "displayNameHtml", "internationalizationEnabled", "registrationEmailAsUsername" ]?seq_contains(key)
|
|
||||||
) || (
|
|
||||||
"applications.ftl" == pageId &&
|
|
||||||
(
|
|
||||||
key == "realm" ||
|
|
||||||
key == "container"
|
|
||||||
) &&
|
|
||||||
is_subpath(path, ["applications", "applications"])
|
|
||||||
) || (
|
|
||||||
key == "delegateForUpdate" &&
|
|
||||||
are_same_path(path, ["user"])
|
|
||||||
) || (
|
|
||||||
<#-- Security audit forwarded by Garth (Gmail) -->
|
|
||||||
key == "saml.signing.private.key" &&
|
|
||||||
are_same_path(path, ["client", "attributes"])
|
|
||||||
) || (
|
|
||||||
<#-- See: https://github.com/keycloakify/keycloakify/issues/534 -->
|
|
||||||
key == "password" &&
|
|
||||||
are_same_path(path, ["login"])
|
|
||||||
) || (
|
|
||||||
<#-- Remove realmAttributes added by https://github.com/jcputney/keycloak-theme-additional-info-extension for peace of mind. -->
|
|
||||||
key == "realmAttributes" &&
|
|
||||||
are_same_path(path, [])
|
|
||||||
) || (
|
|
||||||
<#-- attributesByName adds a lot of noise to the output and is not needed, we already have profile.attributes -->
|
|
||||||
key == "attributesByName" &&
|
|
||||||
are_same_path(path, ["profile"])
|
|
||||||
) || (
|
|
||||||
<#-- We already have the attributes in profile speedup the rendering by filtering it out from the register object -->
|
|
||||||
(key == "attributes" || key == "attributesByName") &&
|
|
||||||
are_same_path(path, ["register"])
|
|
||||||
) || (
|
|
||||||
are_same_path(path, ["properties"]) &&
|
|
||||||
(
|
|
||||||
key?starts_with("kc") ||
|
|
||||||
key == "locales" ||
|
|
||||||
key == "import" ||
|
|
||||||
key == "parent" ||
|
|
||||||
key == "meta" ||
|
|
||||||
key == "stylesCommon" ||
|
|
||||||
key == "styles" ||
|
|
||||||
key == "accountResourceProvider"
|
|
||||||
)
|
|
||||||
) || (
|
|
||||||
key == "execution" &&
|
|
||||||
are_same_path(path, [])
|
|
||||||
) || (
|
|
||||||
key == "entity" &&
|
|
||||||
are_same_path(path, ["user"])
|
|
||||||
)
|
|
||||||
>
|
|
||||||
<#-- <#local out_seq += ["/*" + path?join(".") + "." + key + " excluded*/"]> -->
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#-- https://github.com/keycloakify/keycloakify/discussions/406 -->
|
|
||||||
<#if (
|
|
||||||
["register.ftl", "register-user-profile.ftl", "terms.ftl", "info.ftl", "login.ftl", "login-update-password.ftl", "login-oauth2-device-verify-user-code.ftl"]?seq_contains(pageId) &&
|
|
||||||
key == "attemptedUsername" && are_same_path(path, ["auth"])
|
|
||||||
)>
|
|
||||||
<#attempt>
|
|
||||||
<#-- https://github.com/keycloak/keycloak/blob/3a2bf0c04bcde185e497aaa32d0bb7ab7520cf4a/themes/src/main/resources/theme/base/login/template.ftl#L63 -->
|
|
||||||
<#if !(auth?has_content && auth.showUsername() && !auth.showResetCredentials())>
|
|
||||||
<#local out_seq += ["/*" + path?join(".") + "." + key + " excluded*/"]>
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
|
||||||
<#recover>
|
|
||||||
<#local out_seq += ["/*Accessing attemptedUsername throwed an exception */"]>
|
|
||||||
</#attempt>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
USER_DEFINED_EXCLUSIONS_eKsaY4ZsZ4eMr2
|
<#local outSeq += ['"' + key + '": ' + recOut + ","]>
|
||||||
|
|
||||||
|
</#list>
|
||||||
|
|
||||||
|
<#return (["{"] + outSeq?map(str -> ""?right_pad(4 * (path?size + 1)) + str) + [ ""?right_pad(4 * path?size) + "}"])?join("\n")>
|
||||||
|
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local isMethod = -1>
|
||||||
|
<#attempt>
|
||||||
|
<#local isMethod = object?is_method>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't test if it'sa method.">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
|
<#if isMethod>
|
||||||
|
|
||||||
|
<#if areSamePath(path, ["auth", "showUsername"])>
|
||||||
|
<#attempt>
|
||||||
|
<#return auth.showUsername()?c>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Couldn't evaluate auth.showUsername()">
|
||||||
|
</#attempt>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#if areSamePath(path, ["auth", "showResetCredentials"])>
|
||||||
|
<#attempt>
|
||||||
|
<#return auth.showResetCredentials()?c>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Couldn't evaluate auth.showResetCredentials()">
|
||||||
|
</#attempt>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#if areSamePath(path, ["auth", "showTryAnotherWayLink"])>
|
||||||
|
<#attempt>
|
||||||
|
<#return auth.showTryAnotherWayLink()?c>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Couldn't evaluate auth.showTryAnotherWayLink()">
|
||||||
|
</#attempt>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#if areSamePath(path, ["url", "getLogoutUrl"])>
|
||||||
|
<#local returnValue = -1>
|
||||||
|
<#attempt>
|
||||||
|
<#local returnValue = url.getLogoutUrl()>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Couldn't evaluate url.getLogoutUrl()">
|
||||||
|
</#attempt>
|
||||||
|
<#return 'function(){ return "' + returnValue + '"; }'>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#if areSamePath(path, ["totp", "policy", "getAlgorithmKey"])>
|
||||||
|
<#local returnValue = "error">
|
||||||
|
<#if mode?? && mode = "manual">
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#if !object[key]??>
|
<#local returnValue = totp.policy.getAlgorithmKey()>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Couldn't evaluate totp.policy.getAlgorithmKey()">
|
||||||
|
</#attempt>
|
||||||
|
</#if>
|
||||||
|
<#return 'function(){ return "' + returnValue + '"; }'>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#assign fieldNames = [{{fieldNames}}]>
|
||||||
|
<#if profile?? && profile.attributes??>
|
||||||
|
<#list profile.attributes as attribute>
|
||||||
|
<#if fieldNames?seq_contains(attribute.name)>
|
||||||
|
<#continue>
|
||||||
|
</#if>
|
||||||
|
<#assign fieldNames += [attribute.name]>
|
||||||
|
</#list>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#if areSamePath(path, ["messagesPerField", "get"])>
|
||||||
|
|
||||||
|
<#local jsFunctionCode = "function (fieldName) { ">
|
||||||
|
|
||||||
|
<#list fieldNames as fieldName>
|
||||||
|
|
||||||
|
<#-- See: https://github.com/keycloakify/keycloakify/issues/217 -->
|
||||||
|
<#if xKeycloakify.pageId == "login.ftl" >
|
||||||
|
|
||||||
|
<#if fieldName == "username">
|
||||||
|
|
||||||
|
<#local jsFunctionCode += "if(fieldName === 'username' || fieldName === 'password' ){ ">
|
||||||
|
|
||||||
|
<#if messagesPerField.exists('username') || messagesPerField.exists('password')>
|
||||||
|
<#local jsFunctionCode += "return kcContext.message && kcContext.message.summary ? kcContext.message.summary : 'error'; ">
|
||||||
|
<#else>
|
||||||
|
<#local jsFunctionCode += "return ''; ">
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local jsFunctionCode += "} ">
|
||||||
|
|
||||||
<#continue>
|
<#continue>
|
||||||
</#if>
|
</#if>
|
||||||
<#recover>
|
|
||||||
<#local out_seq += ["/*Couldn't test if '" + key + "' is available on this object*/"]>
|
|
||||||
<#continue>
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#local propertyValue = "">
|
<#if fieldName == "password">
|
||||||
|
<#continue>
|
||||||
<#attempt>
|
|
||||||
<#local propertyValue = object[key]>
|
|
||||||
<#recover>
|
|
||||||
<#local out_seq += ["/*Couldn't dereference '" + key + "' on this object*/"]>
|
|
||||||
<#continue>
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#local rec_out = ftl_object_to_js_code_declaring_an_object(propertyValue, path + [ key ])>
|
|
||||||
|
|
||||||
<#if rec_out?starts_with("ABORT:")>
|
|
||||||
|
|
||||||
<#local errorMessage = rec_out?remove_beginning("ABORT:")>
|
|
||||||
|
|
||||||
<#if errorMessage != " It's a method" >
|
|
||||||
<#local out_seq += ["/*" + key + ": " + errorMessage + "*/"]>
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local out_seq += ['"' + key + '": ' + rec_out + ","]>
|
<#local jsFunctionCode += "if(fieldName === '" + fieldName + "'){ ">
|
||||||
|
|
||||||
|
<#if messagesPerField.exists('${fieldName}')>
|
||||||
|
<#local jsFunctionCode += 'return decodeHtmlEntities("' + messagesPerField.get('${fieldName}')?js_string + '"); '>
|
||||||
|
<#else>
|
||||||
|
<#local jsFunctionCode += "return ''; ">
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local jsFunctionCode += "} ">
|
||||||
|
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
<#return (["{"] + out_seq?map(str -> ""?right_pad(4 * (path?size + 1)) + str) + [ ""?right_pad(4 * path?size) + "}"])?join("\n")>
|
<#local jsFunctionCode += "}">
|
||||||
|
|
||||||
|
<#return jsFunctionCode>
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local isMethod = "">
|
<#if areSamePath(path, ["messagesPerField", "existsError"])>
|
||||||
<#attempt>
|
|
||||||
<#local isMethod = object?is_method>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Can't test if it'sa method.">
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#if isMethod>
|
<#local jsFunctionCode = "function (fieldName) { ">
|
||||||
|
|
||||||
<#if are_same_path(path, ["auth", "showUsername"])>
|
<#list fieldNames as fieldName>
|
||||||
<#attempt>
|
|
||||||
<#return auth.showUsername()?c>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Couldn't evaluate auth.showUsername()">
|
|
||||||
</#attempt>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if are_same_path(path, ["auth", "showResetCredentials"])>
|
<#-- See: https://github.com/keycloakify/keycloakify/issues/217 -->
|
||||||
<#attempt>
|
<#if xKeycloakify.pageId == "login.ftl" >
|
||||||
<#return auth.showResetCredentials()?c>
|
<#if fieldName == "username">
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Couldn't evaluate auth.showResetCredentials()">
|
|
||||||
</#attempt>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if are_same_path(path, ["auth", "showTryAnotherWayLink"])>
|
<#local jsFunctionCode += "if(fieldName === 'username' || fieldName === 'password' ){ ">
|
||||||
<#attempt>
|
|
||||||
<#return auth.showTryAnotherWayLink()?c>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Couldn't evaluate auth.showTryAnotherWayLink()">
|
|
||||||
</#attempt>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if are_same_path(path, ["url", "getLogoutUrl"])>
|
<#if messagesPerField.existsError('username') || messagesPerField.existsError('password')>
|
||||||
<#local returnValue = "">
|
<#local jsFunctionCode += "return true; ">
|
||||||
<#attempt>
|
<#else>
|
||||||
<#local returnValue = url.getLogoutUrl()>
|
<#local jsFunctionCode += "return false; ">
|
||||||
<#recover>
|
</#if>
|
||||||
<#return "ABORT: Couldn't evaluate url.getLogoutUrl()">
|
|
||||||
</#attempt>
|
|
||||||
<#return 'function(){ return "' + returnValue + '"; }'>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if are_same_path(path, ["totp", "policy", "getAlgorithmKey"])>
|
<#local jsFunctionCode += "} ">
|
||||||
<#local returnValue = "error">
|
|
||||||
<#if mode?? && mode = "manual">
|
|
||||||
<#attempt>
|
|
||||||
<#local returnValue = totp.policy.getAlgorithmKey()>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Couldn't evaluate totp.policy.getAlgorithmKey()">
|
|
||||||
</#attempt>
|
|
||||||
</#if>
|
|
||||||
<#return 'function(){ return "' + returnValue + '"; }'>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#assign fieldNames = [ FIELD_NAMES_eKsIY4ZsZ4xeM ]>
|
|
||||||
<#if profile?? && profile.attributes??>
|
|
||||||
<#list profile.attributes as attribute>
|
|
||||||
<#if fieldNames?seq_contains(attribute.name)>
|
|
||||||
<#continue>
|
<#continue>
|
||||||
</#if>
|
</#if>
|
||||||
<#assign fieldNames += [attribute.name]>
|
|
||||||
</#list>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if are_same_path(path, ["messagesPerField", "get"])>
|
|
||||||
|
|
||||||
<#local jsFunctionCode = "function (fieldName) { ">
|
|
||||||
|
|
||||||
<#list fieldNames as fieldName>
|
|
||||||
|
|
||||||
<#-- See: https://github.com/keycloakify/keycloakify/issues/217 -->
|
|
||||||
<#if pageId == "login.ftl" >
|
|
||||||
|
|
||||||
<#if fieldName == "username">
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "if(fieldName === 'username' || fieldName === 'password' ){ ">
|
|
||||||
|
|
||||||
<#if messagesPerField.exists('username') || messagesPerField.exists('password')>
|
|
||||||
<#local jsFunctionCode += "return kcContext.message && kcContext.message.summary ? kcContext.message.summary : 'error'; ">
|
|
||||||
<#else>
|
|
||||||
<#local jsFunctionCode += "return ''; ">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "} ">
|
|
||||||
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if fieldName == "password">
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
|
<#if fieldName == "password">
|
||||||
|
<#continue>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local jsFunctionCode += "if(fieldName === '" + fieldName + "'){ ">
|
|
||||||
|
|
||||||
<#if messagesPerField.exists('${fieldName}')>
|
|
||||||
<#local jsFunctionCode += 'return decodeHtmlEntities("' + messagesPerField.get('${fieldName}')?js_string + '"); '>
|
|
||||||
<#else>
|
|
||||||
<#local jsFunctionCode += "return ''; ">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "} ">
|
|
||||||
|
|
||||||
</#list>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "}">
|
|
||||||
|
|
||||||
<#return jsFunctionCode>
|
|
||||||
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if are_same_path(path, ["messagesPerField", "existsError"])>
|
|
||||||
|
|
||||||
<#local jsFunctionCode = "function (fieldName) { ">
|
|
||||||
|
|
||||||
<#list fieldNames as fieldName>
|
|
||||||
|
|
||||||
<#-- See: https://github.com/keycloakify/keycloakify/issues/217 -->
|
|
||||||
<#if pageId == "login.ftl" >
|
|
||||||
<#if fieldName == "username">
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "if(fieldName === 'username' || fieldName === 'password' ){ ">
|
|
||||||
|
|
||||||
<#if messagesPerField.existsError('username') || messagesPerField.existsError('password')>
|
|
||||||
<#local jsFunctionCode += "return true; ">
|
|
||||||
<#else>
|
|
||||||
<#local jsFunctionCode += "return false; ">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "} ">
|
|
||||||
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if fieldName == "password">
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "if(fieldName === '" + fieldName + "' ){ ">
|
|
||||||
|
|
||||||
<#if messagesPerField.existsError('${fieldName}')>
|
|
||||||
<#local jsFunctionCode += 'return true; '>
|
|
||||||
<#else>
|
|
||||||
<#local jsFunctionCode += "return false; ">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "}">
|
|
||||||
|
|
||||||
</#list>
|
|
||||||
|
|
||||||
<#local jsFunctionCode += "}">
|
|
||||||
|
|
||||||
<#return jsFunctionCode>
|
|
||||||
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if themeType == "account" && are_same_path(path, ["realm", "isInternationalizationEnabled"])>
|
|
||||||
<#attempt>
|
|
||||||
<#return realm.isInternationalizationEnabled()?c>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Couldn't evaluate realm.isInternationalizationEnabled()">
|
|
||||||
</#attempt>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#return "ABORT: It's a method">
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local isBoolean = "">
|
|
||||||
<#attempt>
|
|
||||||
<#local isBoolean = object?is_boolean>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Can't test if it's a boolean">
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#if isBoolean>
|
|
||||||
<#return object?c>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#local isEnumerable = "">
|
|
||||||
<#attempt>
|
|
||||||
<#local isEnumerable = object?is_enumerable>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Can't test if it's an enumerable">
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
|
|
||||||
<#if isEnumerable>
|
|
||||||
|
|
||||||
<#local out_seq = []>
|
|
||||||
|
|
||||||
<#local i = 0>
|
|
||||||
|
|
||||||
<#list object as array_item>
|
|
||||||
|
|
||||||
<#if !array_item??>
|
|
||||||
<#local out_seq += ["null,"]>
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local rec_out = ftl_object_to_js_code_declaring_an_object(array_item, path + [ i ])>
|
<#local jsFunctionCode += "if(fieldName === '" + fieldName + "' ){ ">
|
||||||
|
|
||||||
<#local i = i + 1>
|
<#if messagesPerField.existsError('${fieldName}')>
|
||||||
|
<#local jsFunctionCode += 'return true; '>
|
||||||
<#if rec_out?starts_with("ABORT:")>
|
<#else>
|
||||||
|
<#local jsFunctionCode += "return false; ">
|
||||||
<#local errorMessage = rec_out?remove_beginning("ABORT:")>
|
|
||||||
|
|
||||||
<#if errorMessage != " It's a method" >
|
|
||||||
<#local out_seq += ["/*" + i?string + ": " + errorMessage + "*/"]>
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#continue>
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local out_seq += [rec_out + ","]>
|
<#local jsFunctionCode += "}">
|
||||||
|
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
<#return (["["] + out_seq?map(str -> ""?right_pad(4 * (path?size + 1)) + str) + [ ""?right_pad(4 * path?size) + "]"])?join("\n")>
|
<#local jsFunctionCode += "}">
|
||||||
|
|
||||||
|
<#return jsFunctionCode>
|
||||||
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local isDate = "">
|
<#if xKeycloakify.themeType == "account" && areSamePath(path, ["realm", "isInternationalizationEnabled"])>
|
||||||
<#attempt>
|
<#attempt>
|
||||||
<#local isDate = object?is_date_like>
|
<#return realm.isInternationalizationEnabled()?c>
|
||||||
<#recover>
|
<#recover>
|
||||||
<#return "ABORT: Can't test if it's a date">
|
<#return "ABORT: Couldn't evaluate realm.isInternationalizationEnabled()">
|
||||||
</#attempt>
|
</#attempt>
|
||||||
|
|
||||||
<#if isDate>
|
|
||||||
<#return '"' + object?datetime?iso_utc + '"'>
|
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<#local isNumber = "">
|
<#return "ABORT: It's a method">
|
||||||
<#attempt>
|
</#if>
|
||||||
<#local isNumber = object?is_number>
|
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Can't test if it's a number">
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#if isNumber>
|
<#local isBoolean = -1>
|
||||||
<#return object?c>
|
<#attempt>
|
||||||
</#if>
|
<#local isBoolean = object?is_boolean>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't test if it's a boolean">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
<#local isString = "">
|
<#if isBoolean>
|
||||||
<#attempt>
|
<#return object?c>
|
||||||
<#local isString = object?is_string>
|
</#if>
|
||||||
<#recover>
|
|
||||||
<#return "ABORT: Can't test if it's a string">
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#if isString>
|
<#local isEnumerable = -1>
|
||||||
<@addToXKeycloakifyMessagesIfMessageKey str=object />
|
<#attempt>
|
||||||
</#if>
|
<#local isEnumerable = object?is_enumerable>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't test if it's an enumerable">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
<#attempt>
|
|
||||||
<#return '"' + object?js_string + '"'>;
|
|
||||||
<#recover>
|
|
||||||
</#attempt>
|
|
||||||
|
|
||||||
<#return "ABORT: Couldn't convert into string non hash, non method, non boolean, non number, non enumerable object">
|
<#if isEnumerable>
|
||||||
|
|
||||||
|
<#local outSeq = []>
|
||||||
|
|
||||||
|
<#local i = 0>
|
||||||
|
|
||||||
|
<#list object as array_item>
|
||||||
|
|
||||||
|
<#if !array_item??>
|
||||||
|
<#local outSeq += ["null,"]>
|
||||||
|
<#continue>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local recOut = toJsDeclarationString(array_item, path + [ i ])>
|
||||||
|
|
||||||
|
<#local i = i + 1>
|
||||||
|
|
||||||
|
<#if recOut?starts_with("ABORT:")>
|
||||||
|
|
||||||
|
<#local errorMessage = recOut?remove_beginning("ABORT:")>
|
||||||
|
|
||||||
|
<#if errorMessage != " It's a method" >
|
||||||
|
<#local outSeq += ["/*" + i?string + ": " + errorMessage + "*/"]>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#continue>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local outSeq += [recOut + ","]>
|
||||||
|
|
||||||
|
</#list>
|
||||||
|
|
||||||
|
<#return (["["] + outSeq?map(str -> ""?right_pad(4 * (path?size + 1)) + str) + [ ""?right_pad(4 * path?size) + "]"])?join("\n")>
|
||||||
|
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local isDate = -1>
|
||||||
|
<#attempt>
|
||||||
|
<#local isDate = object?is_date_like>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't test if it's a date">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
|
<#if isDate>
|
||||||
|
<#return '"' + object?datetime?iso_utc + '"'>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local isNumber = -1>
|
||||||
|
<#attempt>
|
||||||
|
<#local isNumber = object?is_number>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't test if it's a number">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
|
<#if isNumber>
|
||||||
|
<#return object?c>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#local isString = -1>
|
||||||
|
<#attempt>
|
||||||
|
<#local isString = object?is_string>
|
||||||
|
<#recover>
|
||||||
|
<#return "ABORT: Can't test if it's a string">
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
|
<#if isString>
|
||||||
|
<@addToXKeycloakifyMessagesIfMessageKey str=object />
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#attempt>
|
||||||
|
<#return 'decodeHtmlEntities("' + object?js_string + '")'>;
|
||||||
|
<#recover>
|
||||||
|
</#attempt>
|
||||||
|
|
||||||
|
<#return "ABORT: Couldn't convert into string non hash, non method, non boolean, non number, non enumerable object">
|
||||||
|
|
||||||
</#function>
|
</#function>
|
||||||
<#function is_subpath path searchedPath>
|
<#function isSubpath path searchedPath>
|
||||||
|
|
||||||
<#if path?size < searchedPath?size>
|
<#if path?size < searchedPath?size>
|
||||||
<#return false>
|
<#return false>
|
||||||
@ -567,8 +578,8 @@ function decodeHtmlEntities(htmlStr){
|
|||||||
|
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#function are_same_path path searchedPath>
|
<#function areSamePath path searchedPath>
|
||||||
<#return path?size == searchedPath?size && is_subpath(path, searchedPath)>
|
<#return path?size == searchedPath?size && isSubpath(path, searchedPath)>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#macro addToXKeycloakifyMessagesIfMessageKey str>
|
<#macro addToXKeycloakifyMessagesIfMessageKey str>
|
||||||
@ -589,15 +600,17 @@ function decodeHtmlEntities(htmlStr){
|
|||||||
<#if resolvedMsg==key>
|
<#if resolvedMsg==key>
|
||||||
<#return>
|
<#return>
|
||||||
</#if>
|
</#if>
|
||||||
<#assign xKeycloakifyMessages = xKeycloakifyMessages + { "${key}": resolvedMsg }>
|
<#local messages=xKeycloakify.messages>
|
||||||
|
<#local messages = messages + { key: resolvedMsg }>
|
||||||
|
<#assign xKeycloakify = xKeycloakify + { "messages": messages }>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#function removeBrackets str>
|
<#function removeBrackets str>
|
||||||
<#if str?starts_with("${") && str?ends_with("}")>
|
<#if str?starts_with("${") && str?ends_with("}")>
|
||||||
<#return str[2..(str?length-2)]>
|
<#return str[2..(str?length-2)]>
|
||||||
<#else>
|
<#else>
|
||||||
<#return str>
|
<#return str>
|
||||||
</#if>
|
</#if>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#macro addNonAutomaticallyGatherableMessagesToXKeycloakifyMessages>
|
<#macro addNonAutomaticallyGatherableMessagesToXKeycloakifyMessages>
|
||||||
@ -625,7 +638,7 @@ function decodeHtmlEntities(htmlStr){
|
|||||||
</#list>
|
</#list>
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
<#if pageId == "terms.ftl" || termsAcceptanceRequired?? && termsAcceptanceRequired>
|
<#if xKeycloakify.pageId == "terms.ftl" || termsAcceptanceRequired?? && termsAcceptanceRequired>
|
||||||
<@addToXKeycloakifyMessagesIfMessageKey str="termsText" />
|
<@addToXKeycloakifyMessagesIfMessageKey str="termsText" />
|
||||||
</#if>
|
</#if>
|
||||||
<#if requiredActions?? && requiredActions?is_enumerable>
|
<#if requiredActions?? && requiredActions?is_enumerable>
|
||||||
@ -637,5 +650,3 @@ function decodeHtmlEntities(htmlStr){
|
|||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,8 +140,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
const { fixedCssCode } = replaceImportsInCssCode({
|
const { fixedCssCode } = replaceImportsInCssCode({
|
||||||
cssCode: sourceCode.toString("utf8"),
|
cssCode: sourceCode.toString("utf8"),
|
||||||
cssFileRelativeDirPath: pathDirname(fileRelativePath),
|
cssFileRelativeDirPath: pathDirname(fileRelativePath),
|
||||||
buildContext,
|
buildContext
|
||||||
isAccountV3
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -176,8 +175,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
fieldNames: readFieldNameUsage({
|
fieldNames: readFieldNameUsage({
|
||||||
themeSrcDirPath: buildContext.themeSrcDirPath,
|
themeSrcDirPath: buildContext.themeSrcDirPath,
|
||||||
themeType
|
themeType
|
||||||
}),
|
})
|
||||||
isAccountV3
|
|
||||||
});
|
});
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -31,8 +31,8 @@ export function generateResourcesForThemeVariant(params: {
|
|||||||
Buffer.from(sourceCode)
|
Buffer.from(sourceCode)
|
||||||
.toString("utf-8")
|
.toString("utf-8")
|
||||||
.replace(
|
.replace(
|
||||||
`kcContext.themeName = "${themeName}";`,
|
`"themeName": "${themeName}"`,
|
||||||
`kcContext.themeName = "${themeVariantName}";`
|
`"themeName": "${themeVariantName}"`
|
||||||
),
|
),
|
||||||
"utf8"
|
"utf8"
|
||||||
);
|
);
|
||||||
|
@ -12,12 +12,11 @@ assert<BuildContext extends BuildContextLike ? true : false>();
|
|||||||
export function replaceImportsInCssCode(params: {
|
export function replaceImportsInCssCode(params: {
|
||||||
cssCode: string;
|
cssCode: string;
|
||||||
cssFileRelativeDirPath: string | undefined;
|
cssFileRelativeDirPath: string | undefined;
|
||||||
isAccountV3: boolean;
|
|
||||||
buildContext: BuildContextLike;
|
buildContext: BuildContextLike;
|
||||||
}): {
|
}): {
|
||||||
fixedCssCode: string;
|
fixedCssCode: string;
|
||||||
} {
|
} {
|
||||||
const { cssCode, cssFileRelativeDirPath, buildContext, isAccountV3 } = params;
|
const { cssCode, cssFileRelativeDirPath, buildContext } = params;
|
||||||
|
|
||||||
const fixedCssCode = cssCode.replace(
|
const fixedCssCode = cssCode.replace(
|
||||||
/url\(["']?(\/[^/][^)"']+)["']?\)/g,
|
/url\(["']?(\/[^/][^)"']+)["']?\)/g,
|
||||||
@ -38,7 +37,7 @@ export function replaceImportsInCssCode(params: {
|
|||||||
break inline_style_in_html;
|
break inline_style_in_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `url(\${${!isAccountV3 ? "url.resourcesPath" : "resourceUrl"}}/${basenameOfTheKeycloakifyResourcesDir}${assetFileAbsoluteUrlPathname})`;
|
return `url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}${assetFileAbsoluteUrlPathname})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetFileRelativeUrlPathname = posix.relative(
|
const assetFileRelativeUrlPathname = posix.relative(
|
||||||
|
@ -31,13 +31,13 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
|
|
||||||
let fixedJsCode = jsCode;
|
let fixedJsCode = jsCode;
|
||||||
|
|
||||||
replace_base_javacript_import: {
|
replace_base_js_import: {
|
||||||
if (buildContext.urlPathname === undefined) {
|
if (buildContext.urlPathname === undefined) {
|
||||||
break replace_base_javacript_import;
|
break replace_base_js_import;
|
||||||
}
|
}
|
||||||
// Optimization
|
// Optimization
|
||||||
if (!jsCode.includes(buildContext.urlPathname)) {
|
if (!jsCode.includes(buildContext.urlPathname)) {
|
||||||
break replace_base_javacript_import;
|
break replace_base_js_import;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace `Hv=function(e){return"/abcde12345/"+e}` by `Hv=function(e){return"/"+e}`
|
// Replace `Hv=function(e){return"/abcde12345/"+e}` by `Hv=function(e){return"/"+e}`
|
||||||
@ -85,13 +85,13 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
fixedJsCode = replaceAll(
|
fixedJsCode = replaceAll(
|
||||||
fixedJsCode,
|
fixedJsCode,
|
||||||
`"${relativePathOfAssetFile}"`,
|
`"${relativePathOfAssetFile}"`,
|
||||||
`(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
`(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
||||||
);
|
);
|
||||||
|
|
||||||
fixedJsCode = replaceAll(
|
fixedJsCode = replaceAll(
|
||||||
fixedJsCode,
|
fixedJsCode,
|
||||||
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
||||||
`(window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
`(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ export function replaceImportsInJsCode_webpack(params: {
|
|||||||
var pd = Object.getOwnPropertyDescriptor(${n}, "p");
|
var pd = Object.getOwnPropertyDescriptor(${n}, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(${n}, "p", {
|
Object.defineProperty(${n}, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
|
||||||
set: function() {}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ export function replaceImportsInJsCode_webpack(params: {
|
|||||||
`[a-zA-Z]+\\.[a-zA-Z]+\\+"${staticDir.replace(/\//g, "\\/")}`,
|
`[a-zA-Z]+\\.[a-zA-Z]+\\+"${staticDir.replace(/\//g, "\\/")}`,
|
||||||
"g"
|
"g"
|
||||||
),
|
),
|
||||||
`window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${staticDir}`
|
`window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${staticDir}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return { fixedJsCode };
|
return { fixedJsCode };
|
||||||
|
@ -172,7 +172,7 @@ export function keycloakify(params?: Params) {
|
|||||||
`(`,
|
`(`,
|
||||||
`(window.kcContext === undefined || import.meta.env.MODE === "development")?`,
|
`(window.kcContext === undefined || import.meta.env.MODE === "development")?`,
|
||||||
`"${urlPathname ?? "/"}":`,
|
`"${urlPathname ?? "/"}":`,
|
||||||
`(window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/")`,
|
`(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/")`,
|
||||||
`)`
|
`)`
|
||||||
].join("")
|
].join("")
|
||||||
);
|
);
|
||||||
|
@ -87,13 +87,13 @@ describe("js replacer - vite", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
S=(window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
||||||
|
|
||||||
function __vite__mapDeps(indexes) {
|
function __vite__mapDeps(indexes) {
|
||||||
if (!__vite__mapDeps.viteFileDeps) {
|
if (!__vite__mapDeps.viteFileDeps) {
|
||||||
__vite__mapDeps.viteFileDeps = [
|
__vite__mapDeps.viteFileDeps = [
|
||||||
(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/Login-dJpPRzM4.js"),
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/Login-dJpPRzM4.js"),
|
||||||
(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/index-XwzrZ5Gu.js")
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/index-XwzrZ5Gu.js")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
||||||
@ -146,13 +146,13 @@ describe("js replacer - vite", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
S=(window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
||||||
|
|
||||||
function __vite__mapDeps(indexes) {
|
function __vite__mapDeps(indexes) {
|
||||||
if (!__vite__mapDeps.viteFileDeps) {
|
if (!__vite__mapDeps.viteFileDeps) {
|
||||||
__vite__mapDeps.viteFileDeps = [
|
__vite__mapDeps.viteFileDeps = [
|
||||||
(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/Login-dJpPRzM4.js"),
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/Login-dJpPRzM4.js"),
|
||||||
(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/index-XwzrZ5Gu.js")
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/index-XwzrZ5Gu.js")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
||||||
@ -205,13 +205,13 @@ describe("js replacer - vite", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
S=(window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
||||||
|
|
||||||
function __vite__mapDeps(indexes) {
|
function __vite__mapDeps(indexes) {
|
||||||
if (!__vite__mapDeps.viteFileDeps) {
|
if (!__vite__mapDeps.viteFileDeps) {
|
||||||
__vite__mapDeps.viteFileDeps = [
|
__vite__mapDeps.viteFileDeps = [
|
||||||
(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/Login-dJpPRzM4.js"),
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/Login-dJpPRzM4.js"),
|
||||||
(window.kcContext.url.resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/index-XwzrZ5Gu.js")
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/index-XwzrZ5Gu.js")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
||||||
@ -267,13 +267,13 @@ describe("js replacer - webpack", () => {
|
|||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
function f() {
|
function f() {
|
||||||
return window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + ({}[e] || e) + "." + {
|
return window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + ({}[e] || e) + "." + {
|
||||||
3: "0664cdc0"
|
3: "0664cdc0"
|
||||||
}[e] + ".chunk.js"
|
}[e] + ".chunk.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
function sameAsF() {
|
function sameAsF() {
|
||||||
return window.kcContext.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + ({}[e] || e) + "." + {
|
return window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + ({}[e] || e) + "." + {
|
||||||
3: "0664cdc0"
|
3: "0664cdc0"
|
||||||
}[e] + ".chunk.js"
|
}[e] + ".chunk.js"
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ describe("js replacer - webpack", () => {
|
|||||||
var pd = Object.getOwnPropertyDescriptor(__webpack_require__, "p");
|
var pd = Object.getOwnPropertyDescriptor(__webpack_require__, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(__webpack_require__, "p", {
|
Object.defineProperty(__webpack_require__, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
|
||||||
set: function() {}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ describe("js replacer - webpack", () => {
|
|||||||
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(t, "p", {
|
Object.defineProperty(t, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
|
||||||
set: function() {}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ describe("js replacer - webpack", () => {
|
|||||||
var pd = Object.getOwnPropertyDescriptor(n, "p");
|
var pd = Object.getOwnPropertyDescriptor(n, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(n, "p", {
|
Object.defineProperty(n, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
|
||||||
set: function() {}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ describe("js replacer - webpack", () => {
|
|||||||
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
||||||
if( pd === undefined || pd.configurable ){
|
if( pd === undefined || pd.configurable ){
|
||||||
Object.defineProperty(t, "p", {
|
Object.defineProperty(t, "p", {
|
||||||
get: function() { return window.kcContext.url.resourcesPath; },
|
get: function() { return window.kcContext["x-keycloakify"].resourcesPath; },
|
||||||
set: function() {}
|
set: function() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -396,7 +396,6 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: "assets/",
|
cssFileRelativeDirPath: "assets/",
|
||||||
isAccountV3: false,
|
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: undefined
|
urlPathname: undefined
|
||||||
}
|
}
|
||||||
@ -435,7 +434,6 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: "assets/",
|
cssFileRelativeDirPath: "assets/",
|
||||||
isAccountV3: false,
|
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: "/a/b/"
|
urlPathname: "/a/b/"
|
||||||
}
|
}
|
||||||
@ -474,7 +472,6 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: undefined,
|
cssFileRelativeDirPath: undefined,
|
||||||
isAccountV3: false,
|
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: "/a/b/"
|
urlPathname: "/a/b/"
|
||||||
}
|
}
|
||||||
@ -482,15 +479,15 @@ describe("css replacer", () => {
|
|||||||
|
|
||||||
const fixedCssCodeExpected = `
|
const fixedCssCodeExpected = `
|
||||||
.my-div {
|
.my-div {
|
||||||
background: url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/background.png) no-repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/background.png) no-repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div2 {
|
.my-div2 {
|
||||||
background: url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/background.png) repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/background.png) repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div3 {
|
.my-div3 {
|
||||||
background-image: url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/media/something.svg);
|
background-image: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/media/something.svg);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -513,7 +510,6 @@ describe("css replacer", () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
cssFileRelativeDirPath: undefined,
|
cssFileRelativeDirPath: undefined,
|
||||||
isAccountV3: false,
|
|
||||||
buildContext: {
|
buildContext: {
|
||||||
urlPathname: undefined
|
urlPathname: undefined
|
||||||
}
|
}
|
||||||
@ -521,15 +517,15 @@ describe("css replacer", () => {
|
|||||||
|
|
||||||
const fixedCssCodeExpected = `
|
const fixedCssCodeExpected = `
|
||||||
.my-div {
|
.my-div {
|
||||||
background: url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/background.png) no-repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/background.png) no-repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div2 {
|
.my-div2 {
|
||||||
background: url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/background.png) repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/background.png) repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div3 {
|
.my-div3 {
|
||||||
background-image: url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/media/something.svg);
|
background-image: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/media/something.svg);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user