keycloakify
Version:
Framework to create custom Keycloak UIs
1,140 lines (1,057 loc) • 494 kB
JavaScript
#!/usr/bin/env node
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 85400:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
// EXPORTS
__nccwpck_require__.d(__webpack_exports__, {
"s": () => (/* binding */ getBuildContext)
});
// EXTERNAL MODULE: external "url"
var external_url_ = __nccwpck_require__(57310);
// EXTERNAL MODULE: external "path"
var external_path_ = __nccwpck_require__(71017);
// EXTERNAL MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js
var getAbsoluteAndInOsFormatPath = __nccwpck_require__(84794);
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
var lib = __nccwpck_require__(52300);
// EXTERNAL MODULE: external "fs"
var external_fs_ = __nccwpck_require__(57147);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
var assert = __nccwpck_require__(29041);
// EXTERNAL MODULE: external "child_process"
var external_child_process_ = __nccwpck_require__(32081);
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
var constants = __nccwpck_require__(173);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
var exclude = __nccwpck_require__(83101);
;// CONCATENATED MODULE: ./node_modules/tsafe/esm/index.mjs
//# sourceMappingURL=index.mjs.map
// EXTERNAL MODULE: ./dist/bin/tools/crawl.js
var crawl = __nccwpck_require__(73036);
;// CONCATENATED MODULE: ./node_modules/tsafe/esm/objectEntries.mjs
/** https://docs.tsafe.dev/objectentries */
function objectEntries(o) {
return Object.entries(o);
}
//# sourceMappingURL=objectEntries.mjs.map
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
var id = __nccwpck_require__(38469);
// EXTERNAL MODULE: ./node_modules/chalk/source/index.js
var source = __nccwpck_require__(78818);
var source_default = /*#__PURE__*/__nccwpck_require__.n(source);
;// CONCATENATED MODULE: ./dist/bin/tools/fetchProxyOptions.js
function getProxyFetchOptions(params) {
var _a, _b, _c;
const { npmConfigGetCwd } = params;
const cfg = (() => {
const output = external_child_process_.execSync("npm config get", { cwd: npmConfigGetCwd })
.toString("utf8");
return output
.split("\n")
.filter(line => !line.startsWith(";"))
.map(line => line.trim())
.map(line => {
const [key, value] = line.split("=");
if (key === undefined) {
return undefined;
}
if (value === undefined) {
return undefined;
}
return [key.trim(), value.trim()];
})
.filter((0,exclude/* exclude */.D)(undefined))
.filter(([key]) => key !== "")
.map(([key, value]) => {
if (value.startsWith('"') && value.endsWith('"')) {
return [key, value.slice(1, -1)];
}
if (value === "true" || value === "false") {
return [key, value];
}
return undefined;
})
.filter((0,exclude/* exclude */.D)(undefined))
.reduce((cfg, [key, value]) => key in cfg
? Object.assign(Object.assign({}, cfg), { [key]: [...ensureArray(cfg[key]), value] }) : Object.assign(Object.assign({}, cfg), { [key]: value }), {});
})();
const proxy = ensureSingleOrNone((_a = cfg["https-proxy"]) !== null && _a !== void 0 ? _a : cfg["proxy"]);
const noProxy = (_b = cfg["noproxy"]) !== null && _b !== void 0 ? _b : cfg["no-proxy"];
const strictSSL = ensureSingleOrNone(cfg["strict-ssl"]) === "true";
const cert = cfg["cert"];
const ca = ensureArray((_c = cfg["ca"]) !== null && _c !== void 0 ? _c : cfg["ca[]"]);
const cafile = ensureSingleOrNone(cfg["cafile"]);
if (cafile !== undefined) {
ca.push(...(() => {
const cafileContent = external_fs_.readFileSync(cafile).toString("utf8");
const newLinePlaceholder = "NEW_LINE_PLACEHOLDER_xIsPsK23svt";
const chunks = (arr, size = 2) => arr
.map((_, i) => i % size == 0 && arr.slice(i, i + size))
.filter(Boolean);
return chunks(cafileContent.split(/(-----END CERTIFICATE-----)/), 2).map(ca => ca
.join("")
.replace(/\r?\n/g, newLinePlaceholder)
.replace(new RegExp(`^${newLinePlaceholder}`), "")
.replace(new RegExp(newLinePlaceholder, "g"), "\\n"));
})());
}
return {
proxy,
noProxy,
strictSSL,
cert,
ca: ca.length === 0 ? undefined : ca
};
}
function ensureArray(arg0) {
return Array.isArray(arg0) ? arg0 : arg0 === undefined ? [] : [arg0];
}
function ensureSingleOrNone(arg0) {
if (!Array.isArray(arg0))
return arg0;
if (arg0.length === 0)
return undefined;
if (arg0.length === 1)
return arg0[0];
throw new Error("Illegal configuration, expected a single value but found multiple: " +
arg0.map(String).join(", "));
}
//# sourceMappingURL=fetchProxyOptions.js.map
;// CONCATENATED MODULE: ./dist/bin/shared/buildContext.js
(0,assert/* assert */.h)();
function getBuildContext(params) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
const projectDirPath = params.projectDirPath !== undefined
? (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: params.projectDirPath,
cwd: process.cwd()
})
: process.cwd();
const { themeSrcDirPath } = (() => {
const srcDirPath = (0,external_path_.join)(projectDirPath, "src");
const themeSrcDirPath = (0,crawl/* crawl */.J)({
dirPath: srcDirPath,
returnedPathsType: "relative to dirPath"
})
.map(fileRelativePath => {
for (const themeSrcDirBasename of [
constants/* KEYCLOAK_THEME */.PC,
constants/* KEYCLOAK_THEME.replace */.PC.replace(/-/g, "_")
]) {
const split = fileRelativePath.split(themeSrcDirBasename);
if (split.length === 2) {
return (0,external_path_.join)(srcDirPath, split[0] + themeSrcDirBasename);
}
}
return undefined;
})
.filter((0,exclude/* exclude */.D)(undefined))[0];
if (themeSrcDirPath !== undefined) {
return { themeSrcDirPath };
}
return { themeSrcDirPath: srcDirPath };
})();
const { resolvedViteConfig } = (() => {
if (external_fs_.readdirSync(projectDirPath)
.find(fileBasename => fileBasename.startsWith("vite.config")) ===
undefined) {
return { resolvedViteConfig: undefined };
}
let output;
try {
output = external_child_process_.execSync("npx vite", {
cwd: projectDirPath,
stdio: ["pipe", "pipe", "ignore"],
env: Object.assign(Object.assign({}, process.env), { [constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG */.TE.RESOLVE_VITE_CONFIG]: "true" })
})
.toString("utf8");
}
catch (error) {
throw new Error(`Failed to run \`npx vite\`: ${error}`);
}
(0,assert/* assert */.h)(output.includes(constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG */.TE.RESOLVE_VITE_CONFIG), "Seems like the Keycloakify's Vite plugin is not installed.");
const resolvedViteConfigStr = output
.split(constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG */.TE.RESOLVE_VITE_CONFIG)
.reverse()[0];
const resolvedViteConfig = JSON.parse(resolvedViteConfigStr);
return { resolvedViteConfig };
})();
const packageJsonFilePath = (function getPackageJSonDirPath(upCount) {
var _a, _b;
const dirPath = (0,external_path_.resolve)((0,external_path_.join)(...[projectDirPath, ...Array(upCount).fill("..")]));
(0,assert/* assert */.h)(dirPath !== external_path_.sep, "Root package.json not found");
success: {
const packageJsonFilePath = (0,external_path_.join)(dirPath, "package.json");
if (!external_fs_.existsSync(packageJsonFilePath)) {
break success;
}
const parsedPackageJson = lib.z.object({
name: lib.z.string().optional(),
dependencies: lib.z.record(lib.z.string()).optional(),
devDependencies: lib.z.record(lib.z.string()).optional()
})
.parse(JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8")));
if (((_a = parsedPackageJson.dependencies) === null || _a === void 0 ? void 0 : _a.keycloakify) === undefined &&
((_b = parsedPackageJson.devDependencies) === null || _b === void 0 ? void 0 : _b.keycloakify) === undefined) {
break success;
}
return packageJsonFilePath;
}
return getPackageJSonDirPath(upCount + 1);
})(0);
const parsedPackageJson = (() => {
const zMultiPageApp = (() => {
const zTargetType = lib.z.object({
accountThemeImplementation: lib.z.literal("Multi-Page"),
keycloakVersionTargets: lib.z.object({
"21-and-below": lib.z.union([lib.z.boolean(), lib.z.string()]),
"23": lib.z.union([lib.z.boolean(), lib.z.string()]),
"24": lib.z.union([lib.z.boolean(), lib.z.string()]),
"25": lib.z.union([lib.z.boolean(), lib.z.string()]),
"26.0-to-26.1": lib.z.union([lib.z.boolean(), lib.z.string()]),
"26.2-and-above": lib.z.union([lib.z.boolean(), lib.z.string()])
})
.optional()
});
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zSinglePageApp = (() => {
const zTargetType = lib.z.object({
accountThemeImplementation: lib.z.union([
lib.z.literal("Single-Page"),
lib.z.literal("none")
]),
keycloakVersionTargets: lib.z.object({
"22-to-25": lib.z.union([lib.z.boolean(), lib.z.string()]),
"all-other-versions": lib.z.union([lib.z.boolean(), lib.z.string()])
})
.optional()
});
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zAccountThemeImplAndKeycloakVersionTargets = (() => {
const zTargetType = lib.z.union([zMultiPageApp, zSinglePageApp]);
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zStartKeycloakOptions = (() => {
const zTargetType = lib.z.object({
dockerImage: lib.z.string().optional(),
extensionJars: lib.z.array(lib.z.string()).optional(),
realmJsonFilePath: lib.z.string().optional(),
dockerExtraArgs: lib.z.array(lib.z.string()).optional(),
keycloakExtraArgs: lib.z.array(lib.z.string()).optional(),
port: lib.z.number().optional()
});
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zBuildOptions = (() => {
const zTargetType = lib.z.intersection(lib.z.object({
themeName: lib.z.union([lib.z.string(), lib.z.array(lib.z.string())]).optional(),
themeVersion: lib.z.string().optional(),
environmentVariables: lib.z.array(lib.z.object({
name: lib.z.string(),
default: lib.z.string()
}))
.optional(),
extraThemeProperties: lib.z.array(lib.z.string()).optional(),
artifactId: lib.z.string().optional(),
groupId: lib.z.string().optional(),
keycloakifyBuildDirPath: lib.z.string().optional(),
kcContextExclusionsFtl: lib.z.string().optional(),
startKeycloakOptions: zStartKeycloakOptions.optional()
}), zAccountThemeImplAndKeycloakVersionTargets);
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zBuildOptions_packageJson = (() => {
const zTargetType = lib.z.intersection(zBuildOptions, lib.z.object({
projectBuildDirPath: lib.z.string().optional(),
staticDirPathInProjectBuildDirPath: lib.z.string().optional(),
publicDirPath: lib.z.string().optional()
}));
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zParsedPackageJson = (() => {
const zTargetType = lib.z.object({
name: lib.z.string().optional(),
version: lib.z.string().optional(),
homepage: lib.z.string().optional(),
keycloakify: zBuildOptions_packageJson.optional()
});
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const configurationPackageJsonFilePath = (() => {
const rootPackageJsonFilePath = (0,external_path_.join)(projectDirPath, "package.json");
return external_fs_.existsSync(rootPackageJsonFilePath)
? rootPackageJsonFilePath
: packageJsonFilePath;
})();
return zParsedPackageJson.parse(JSON.parse(external_fs_.readFileSync(configurationPackageJsonFilePath).toString("utf8")));
})();
const bundler = resolvedViteConfig !== undefined ? "vite" : "webpack";
if (bundler === "vite" && parsedPackageJson.keycloakify !== undefined) {
console.error(source_default().red(`In vite projects, provide your Keycloakify options in vite.config.ts, not in package.json`));
process.exit(-1);
}
const buildOptions = (() => {
switch (bundler) {
case "vite":
(0,assert/* assert */.h)(resolvedViteConfig !== undefined);
return resolvedViteConfig.buildOptions;
case "webpack":
(0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
return parsedPackageJson.keycloakify;
}
(0,assert/* assert */.h)(false);
})();
const implementedThemeTypes = (() => {
const getIsNative = (dirPath) => external_fs_.existsSync((0,external_path_.join)(dirPath, "theme.properties"));
return {
login: (() => {
const dirPath = (0,external_path_.join)(themeSrcDirPath, "login");
if (!external_fs_.existsSync(dirPath)) {
return { isImplemented: false, isImplemented_native: false };
}
if (getIsNative(dirPath)) {
return { isImplemented: false, isImplemented_native: true };
}
return { isImplemented: true };
})(),
email: (() => {
const dirPath = (0,external_path_.join)(themeSrcDirPath, "email");
if (!external_fs_.existsSync(dirPath) || !getIsNative(dirPath)) {
return { isImplemented: false, isImplemented_native: false };
}
return { isImplemented: false, isImplemented_native: true };
})(),
account: (() => {
const dirPath = (0,external_path_.join)(themeSrcDirPath, "account");
if (!external_fs_.existsSync(dirPath)) {
return { isImplemented: false, isImplemented_native: false };
}
if (getIsNative(dirPath)) {
return { isImplemented: false, isImplemented_native: true };
}
if (buildOptions.accountThemeImplementation === "none") {
return { isImplemented: false, isImplemented_native: false };
}
return {
isImplemented: true,
type: buildOptions.accountThemeImplementation
};
})(),
admin: (() => {
const dirPath = (0,external_path_.join)(themeSrcDirPath, "admin");
if (!external_fs_.existsSync(dirPath)) {
return { isImplemented: false, isImplemented_native: false };
}
if (getIsNative(dirPath)) {
return { isImplemented: false, isImplemented_native: true };
}
return { isImplemented: true };
})()
};
})();
if (implementedThemeTypes.account.isImplemented &&
!external_fs_.existsSync((0,external_path_.join)(themeSrcDirPath, "account"))) {
console.error(source_default().red([
`You have set 'accountThemeImplementation' to '${implementedThemeTypes.account.type}'`,
`but the 'account' directory is missing in your theme source directory`,
"Use the `npx keycloakify initialize-account-theme` command to create it"
].join(" ")));
process.exit(-1);
}
const themeNames = (() => {
const themeNames = (() => {
if (buildOptions.themeName === undefined) {
return parsedPackageJson.name === undefined
? ["keycloakify"]
: [
parsedPackageJson.name
.replace(/^@(.*)/, "$1")
.split("/")
.join("-")
];
}
if (typeof buildOptions.themeName === "string") {
return [buildOptions.themeName];
}
const [mainThemeName, ...themeVariantNames] = buildOptions.themeName;
(0,assert/* assert */.h)(mainThemeName !== undefined);
return [mainThemeName, ...themeVariantNames];
})();
for (const themeName of themeNames) {
if (!/^[a-zA-Z0-9_-]+$/.test(themeName)) {
console.error(source_default().red([
`Invalid theme name: ${themeName}`,
`Theme names should only contain letters, numbers, and "_" or "-"`
].join(" ")));
process.exit(-1);
}
}
return themeNames;
})();
const relativePathsCwd = (() => {
switch (bundler) {
case "vite":
return projectDirPath;
case "webpack":
return (0,external_path_.dirname)(packageJsonFilePath);
}
})();
const projectBuildDirPath = (() => {
webpack: {
if (bundler !== "webpack") {
break webpack;
}
(0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
if (parsedPackageJson.keycloakify.projectBuildDirPath !== undefined) {
return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath,
cwd: relativePathsCwd
});
}
return (0,external_path_.join)(projectDirPath, "build");
}
(0,assert/* assert */.h)(bundler === "vite");
(0,assert/* assert */.h)(resolvedViteConfig !== undefined);
return (0,external_path_.join)(projectDirPath, resolvedViteConfig.buildDir);
})();
return {
bundler,
packageJsonFilePath,
themeVersion: (_b = (_a = buildOptions.themeVersion) !== null && _a !== void 0 ? _a : parsedPackageJson.version) !== null && _b !== void 0 ? _b : "0.0.0",
themeNames,
extraThemeProperties: buildOptions.extraThemeProperties,
groupId: (() => {
var _a, _b, _c, _d, _e;
const fallbackGroupId = `${themeNames[0]}.keycloak`;
return ((_b = (_a = process.env.KEYCLOAKIFY_GROUP_ID) !== null && _a !== void 0 ? _a : buildOptions.groupId) !== null && _b !== void 0 ? _b : (parsedPackageJson.homepage === undefined
? fallbackGroupId
: (_e = (_d = (_c = (0,external_url_.parse)(parsedPackageJson.homepage)
.host) === null || _c === void 0 ? void 0 : _c.replace(/:[0-9]+$/, "")) === null || _d === void 0 ? void 0 : _d.split(".").reverse().join(".")) !== null && _e !== void 0 ? _e : fallbackGroupId) + ".keycloak");
})(),
artifactId: (_d = (_c = process.env.KEYCLOAKIFY_ARTIFACT_ID) !== null && _c !== void 0 ? _c : buildOptions.artifactId) !== null && _d !== void 0 ? _d : `${themeNames[0]}-keycloak-theme`,
projectDirPath,
projectBuildDirPath,
keycloakifyBuildDirPath: (() => {
if (buildOptions.keycloakifyBuildDirPath !== undefined) {
return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: buildOptions.keycloakifyBuildDirPath,
cwd: relativePathsCwd
});
}
return (0,external_path_.join)(projectDirPath, (resolvedViteConfig === null || resolvedViteConfig === void 0 ? void 0 : resolvedViteConfig.buildDir) === undefined
? "build_keycloak"
: `${resolvedViteConfig.buildDir}_keycloak`);
})(),
publicDirPath: (() => {
if (process.env.PUBLIC_DIR_PATH !== undefined) {
return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: process.env.PUBLIC_DIR_PATH,
cwd: projectDirPath
});
}
webpack: {
if (bundler !== "webpack") {
break webpack;
}
(0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: parsedPackageJson.keycloakify.publicDirPath,
cwd: relativePathsCwd
});
}
return (0,external_path_.join)(projectDirPath, "public");
}
(0,assert/* assert */.h)(bundler === "vite");
(0,assert/* assert */.h)(resolvedViteConfig !== undefined);
return (0,external_path_.join)(projectDirPath, resolvedViteConfig.publicDir);
})(),
cacheDirPath: (0,external_path_.join)((() => {
if (process.env.XDG_CACHE_HOME !== undefined) {
return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: process.env.XDG_CACHE_HOME,
cwd: process.cwd()
});
}
return (0,external_path_.join)((0,external_path_.dirname)(packageJsonFilePath), "node_modules", ".cache");
})(), "keycloakify"),
urlPathname: (() => {
webpack: {
if (bundler !== "webpack") {
break webpack;
}
const { homepage } = parsedPackageJson;
let url = undefined;
if (homepage !== undefined) {
url = new URL(homepage);
}
if (url === undefined) {
return undefined;
}
const out = url.pathname.replace(/([^/])$/, "$1/");
return out === "/" ? undefined : out;
}
(0,assert/* assert */.h)(bundler === "vite");
(0,assert/* assert */.h)(resolvedViteConfig !== undefined);
return resolvedViteConfig.urlPathname;
})(),
assetsDirPath: (() => {
webpack: {
if (bundler !== "webpack") {
break webpack;
}
(0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
if (parsedPackageJson.keycloakify.staticDirPathInProjectBuildDirPath !==
undefined) {
(0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: parsedPackageJson.keycloakify
.staticDirPathInProjectBuildDirPath,
cwd: relativePathsCwd
});
}
return (0,external_path_.join)(projectBuildDirPath, "static");
}
(0,assert/* assert */.h)(bundler === "vite");
(0,assert/* assert */.h)(resolvedViteConfig !== undefined);
return (0,external_path_.join)(projectBuildDirPath, resolvedViteConfig.assetsDir);
})(),
kcContextExclusionsFtlCode: (() => {
if (buildOptions.kcContextExclusionsFtl === undefined) {
return undefined;
}
if (buildOptions.kcContextExclusionsFtl.endsWith(".ftl")) {
const kcContextExclusionsFtlPath = (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: buildOptions.kcContextExclusionsFtl,
cwd: projectDirPath
});
return external_fs_.readFileSync(kcContextExclusionsFtlPath).toString("utf8");
}
return buildOptions.kcContextExclusionsFtl;
})(),
environmentVariables: (_e = buildOptions.environmentVariables) !== null && _e !== void 0 ? _e : [],
implementedThemeTypes,
themeSrcDirPath,
get fetchOptions() {
return getProxyFetchOptions({
npmConfigGetCwd: (function callee(upCount) {
const dirPath = (0,external_path_.resolve)((0,external_path_.join)(...[projectDirPath, ...Array(upCount).fill("..")]));
(0,assert/* assert */.h)(dirPath !== external_path_.sep, "Couldn't find a place to run 'npm config get'");
try {
external_child_process_.execSync("npm config get", {
cwd: dirPath,
stdio: "pipe"
});
}
catch (error) {
if (String(error).includes("ENOWORKSPACES")) {
return callee(upCount + 1);
}
throw error;
}
return dirPath;
})(0)
});
},
jarTargets: (() => {
const getDefaultJarFileBasename = (range) => `keycloak-theme-for-kc-${range}.jar`;
build_for_specific_keycloak_major_version: {
const buildForKeycloakMajorVersionNumber = (() => {
const envValue = process.env[constants/* BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME */.ac];
if (envValue === undefined) {
return undefined;
}
const major = parseInt(envValue);
(0,assert/* assert */.h)(!isNaN(major));
return major;
})();
if (buildForKeycloakMajorVersionNumber === undefined) {
break build_for_specific_keycloak_major_version;
}
const keycloakVersionRange = (() => {
if (implementedThemeTypes.account.isImplemented &&
implementedThemeTypes.account.type === "Multi-Page") {
const keycloakVersionRange = (() => {
if (buildForKeycloakMajorVersionNumber <= 21) {
return "21-and-below";
}
(0,assert/* assert */.h)(buildForKeycloakMajorVersionNumber !== 22);
if (buildForKeycloakMajorVersionNumber === 23) {
return "23";
}
if (buildForKeycloakMajorVersionNumber === 24) {
return "24";
}
if (buildForKeycloakMajorVersionNumber === 25) {
return "25";
}
return "26.2-and-above";
})();
(0,assert/* assert */.h)();
return keycloakVersionRange;
}
else {
const keycloakVersionRange = (() => {
if (buildForKeycloakMajorVersionNumber <= 21 ||
buildForKeycloakMajorVersionNumber >= 26) {
return "all-other-versions";
}
return "22-to-25";
})();
(0,assert/* assert */.h)();
return keycloakVersionRange;
}
})();
const jarFileBasename = (() => {
use_custom_jar_basename: {
const { keycloakVersionTargets } = buildOptions;
(0,assert/* assert */.h)((0,assert.is)(keycloakVersionTargets));
if (keycloakVersionTargets === undefined) {
break use_custom_jar_basename;
}
const entry = objectEntries(keycloakVersionTargets).find(([keycloakVersionRange_entry]) => keycloakVersionRange_entry === keycloakVersionRange);
if (entry === undefined) {
break use_custom_jar_basename;
}
const maybeJarFileBasename = entry[1];
if (typeof maybeJarFileBasename !== "string") {
break use_custom_jar_basename;
}
return maybeJarFileBasename;
}
return getDefaultJarFileBasename(keycloakVersionRange);
})();
return [
{
keycloakVersionRange,
jarFileBasename
}
];
}
const jarTargets_default = (() => {
const jarTargets = [];
if (implementedThemeTypes.account.isImplemented &&
implementedThemeTypes.account.type === "Multi-Page") {
for (const keycloakVersionRange of [
"21-and-below",
"23",
"24",
"25",
"26.0-to-26.1",
"26.2-and-above"
]) {
(0,assert/* assert */.h)(true);
jarTargets.push({
keycloakVersionRange,
jarFileBasename: getDefaultJarFileBasename(keycloakVersionRange)
});
}
}
else {
for (const keycloakVersionRange of [
"22-to-25",
"all-other-versions"
]) {
(0,assert/* assert */.h)(true);
jarTargets.push({
keycloakVersionRange,
jarFileBasename: getDefaultJarFileBasename(keycloakVersionRange)
});
}
}
return jarTargets;
})();
if (buildOptions.keycloakVersionTargets === undefined) {
return jarTargets_default;
}
const jarTargets = [];
for (const [keycloakVersionRange, jarNameOrBoolean] of objectEntries((() => {
const { keycloakVersionTargets } = buildOptions;
(0,assert/* assert */.h)((0,assert.is)(keycloakVersionTargets));
return keycloakVersionTargets;
})())) {
if (jarNameOrBoolean === false) {
continue;
}
if (jarNameOrBoolean === true) {
jarTargets.push({
keycloakVersionRange: keycloakVersionRange,
jarFileBasename: getDefaultJarFileBasename(keycloakVersionRange)
});
continue;
}
const jarFileBasename = jarNameOrBoolean;
if (!jarFileBasename.endsWith(".jar")) {
console.log(source_default().red(`Bad ${jarFileBasename} should end with '.jar'\n`));
process.exit(1);
}
if (jarFileBasename.includes("/") || jarFileBasename.includes("\\")) {
console.log(source_default().red([
`Invalid ${jarFileBasename}. It's not supposed to be a path,`,
`Only the basename of the jar file is expected.`,
`Example: keycloak-theme.jar`
].join(" ")));
process.exit(1);
}
jarTargets.push({
keycloakVersionRange: keycloakVersionRange,
jarFileBasename: jarNameOrBoolean
});
}
if (jarTargets.length === 0) {
console.log(source_default().red("All jar targets are disabled. Please enable at least one jar target."));
process.exit(1);
}
return jarTargets;
})(),
startKeycloakOptions: {
dockerImage: (() => {
var _a;
if (((_a = buildOptions.startKeycloakOptions) === null || _a === void 0 ? void 0 : _a.dockerImage) === undefined) {
return undefined;
}
const [reference, tag, ...rest] = buildOptions.startKeycloakOptions.dockerImage.split(":");
(0,assert/* assert */.h)(reference !== undefined && tag !== undefined && rest.length === 0, `Invalid docker image: ${buildOptions.startKeycloakOptions.dockerImage}`);
return { reference, tag };
})(),
dockerExtraArgs: (_g = (_f = buildOptions.startKeycloakOptions) === null || _f === void 0 ? void 0 : _f.dockerExtraArgs) !== null && _g !== void 0 ? _g : [],
keycloakExtraArgs: (_j = (_h = buildOptions.startKeycloakOptions) === null || _h === void 0 ? void 0 : _h.keycloakExtraArgs) !== null && _j !== void 0 ? _j : [],
extensionJars: ((_l = (_k = buildOptions.startKeycloakOptions) === null || _k === void 0 ? void 0 : _k.extensionJars) !== null && _l !== void 0 ? _l : []).map(urlOrPath => {
if (/^https?:\/\//.test(urlOrPath)) {
return { type: "url", url: urlOrPath };
}
return {
type: "path",
path: (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: urlOrPath,
cwd: relativePathsCwd
})
};
}),
realmJsonFilePath: ((_m = buildOptions.startKeycloakOptions) === null || _m === void 0 ? void 0 : _m.realmJsonFilePath) === undefined
? undefined
: (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
pathIsh: buildOptions.startKeycloakOptions.realmJsonFilePath,
cwd: relativePathsCwd
}),
port: (_o = buildOptions.startKeycloakOptions) === null || _o === void 0 ? void 0 : _o.port
}
};
}
//# sourceMappingURL=buildContext.js.map
/***/ }),
/***/ 173:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "Jh": () => (/* binding */ THEME_TYPES),
/* harmony export */ "Ju": () => (/* binding */ WELL_KNOWN_DIRECTORY_BASE_NAME),
/* harmony export */ "PC": () => (/* binding */ KEYCLOAK_THEME),
/* harmony export */ "Sz": () => (/* binding */ KEYCLOAKIFY_SPA_DEV_SERVER_PORT),
/* harmony export */ "TE": () => (/* binding */ VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES),
/* harmony export */ "Tr": () => (/* binding */ KEYCLOAKIFY_LOGIN_JAR_BASENAME),
/* harmony export */ "XV": () => (/* binding */ LOGIN_THEME_PAGE_IDS),
/* harmony export */ "_L": () => (/* binding */ FALLBACK_LANGUAGE_TAG),
/* harmony export */ "_S": () => (/* binding */ CUSTOM_HANDLER_ENV_NAMES),
/* harmony export */ "ac": () => (/* binding */ BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME),
/* harmony export */ "jp": () => (/* binding */ TEST_APP_URL),
/* harmony export */ "sv": () => (/* binding */ CONTAINER_NAME),
/* harmony export */ "yV": () => (/* binding */ ACCOUNT_THEME_PAGE_IDS)
/* harmony export */ });
/* unused harmony export KEYCLOAKIFY_LOGGING_VERSION */
const WELL_KNOWN_DIRECTORY_BASE_NAME = {
KEYCLOAKIFY_DEV_RESOURCES: "keycloakify-dev-resources",
RESOURCES_COMMON: "resources-common",
DIST: "dist"
};
const THEME_TYPES = ["login", "account", "admin"];
const VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES = {
RUN_POST_BUILD_SCRIPT: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
RESOLVE_VITE_CONFIG: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG",
READ_KC_CONTEXT_FROM_URL: "KEYCLOAKIFY_READ_KC_CONTEXT_FROM_URL"
};
const BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME = "KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
const LOGIN_THEME_PAGE_IDS = [
"login.ftl",
"login-username.ftl",
"login-password.ftl",
"webauthn-authenticate.ftl",
"webauthn-register.ftl",
"register.ftl",
"info.ftl",
"error.ftl",
"login-reset-password.ftl",
"login-verify-email.ftl",
"terms.ftl",
"login-oauth2-device-verify-user-code.ftl",
"login-oauth-grant.ftl",
"login-otp.ftl",
"login-update-profile.ftl",
"login-update-password.ftl",
"login-idp-link-confirm.ftl",
"login-idp-link-email.ftl",
"login-page-expired.ftl",
"login-config-totp.ftl",
"logout-confirm.ftl",
"idp-review-user-profile.ftl",
"update-email.ftl",
"select-authenticator.ftl",
"saml-post-form.ftl",
"delete-credential.ftl",
"code.ftl",
"delete-account-confirm.ftl",
"frontchannel-logout.ftl",
"login-recovery-authn-code-config.ftl",
"login-recovery-authn-code-input.ftl",
"login-reset-otp.ftl",
"login-x509-info.ftl",
"webauthn-error.ftl",
"login-passkeys-conditional-authenticate.ftl",
"login-idp-link-confirm-override.ftl"
];
const ACCOUNT_THEME_PAGE_IDS = [
"password.ftl",
"account.ftl",
"sessions.ftl",
"totp.ftl",
"applications.ftl",
"log.ftl",
"federatedIdentity.ftl"
];
const CONTAINER_NAME = "keycloak-keycloakify";
const FALLBACK_LANGUAGE_TAG = "en";
const CUSTOM_HANDLER_ENV_NAMES = {
COMMAND_NAME: "KEYCLOAKIFY_COMMAND_NAME",
BUILD_CONTEXT: "KEYCLOAKIFY_BUILD_CONTEXT"
};
const KEYCLOAK_THEME = "keycloak-theme";
const KEYCLOAKIFY_SPA_DEV_SERVER_PORT = "KEYCLOAKIFY_SPA_DEV_SERVER_PORT";
const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
const KEYCLOAKIFY_LOGIN_JAR_BASENAME = `keycloakify-logging-${KEYCLOAKIFY_LOGGING_VERSION}.jar`;
const TEST_APP_URL = "https://my-theme.keycloakify.dev";
//# sourceMappingURL=constants.js.map
/***/ }),
/***/ 73036:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "J": () => (/* binding */ crawl)
/* harmony export */ });
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(57147);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
const crawlRec = (dirPath, filePaths) => {
for (const basename of fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dirPath)) {
const fileOrDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, basename);
if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(fileOrDirPath).isDirectory()) {
crawlRec(fileOrDirPath, filePaths);
continue;
}
filePaths.push(fileOrDirPath);
}
};
/** List all files in a given directory return paths relative to the dir_path */
function crawl(params) {
const { dirPath, returnedPathsType } = params;
const filePaths = [];
crawlRec(dirPath, filePaths);
switch (returnedPathsType) {
case "absolute":
return filePaths;
case "relative to dirPath":
return filePaths.map(filePath => (0,path__WEBPACK_IMPORTED_MODULE_1__.relative)(dirPath, filePath));
}
}
//# sourceMappingURL=crawl.js.map
/***/ }),
/***/ 84794:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "c": () => (/* binding */ getAbsoluteAndInOsFormatPath)
/* harmony export */ });
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(22037);
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_1__);
function getAbsoluteAndInOsFormatPath(params) {
const { pathIsh, cwd } = params;
let pathOut = pathIsh;
pathOut = pathOut.replace(/^['"]/, "").replace(/['"]$/, "");
pathOut = pathOut.replace(/\//g, path__WEBPACK_IMPORTED_MODULE_0__.sep);
if (pathOut.startsWith("~")) {
pathOut = pathOut.replace("~", os__WEBPACK_IMPORTED_MODULE_1__.homedir());
}
pathOut = pathOut.endsWith(path__WEBPACK_IMPORTED_MODULE_0__.sep) ? pathOut.slice(0, -1) : pathOut;
if (!(0,path__WEBPACK_IMPORTED_MODULE_0__.isAbsolute)(pathOut)) {
pathOut = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(cwd, pathOut);
}
pathOut = (0,path__WEBPACK_IMPORTED_MODULE_0__.resolve)(pathOut);
return pathOut;
}
//# sourceMappingURL=getAbsoluteAndInOsFormatPath.js.map
/***/ }),
/***/ 58822:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "B": () => (/* binding */ getNearestPackageJsonDirPath),
/* harmony export */ "e": () => (/* binding */ getThisCodebaseRootDirPath)
/* harmony export */ });
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(57147);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
let result = undefined;
function getThisCodebaseRootDirPath() {
if (result !== undefined) {
return result;
}
return (result = getNearestPackageJsonDirPath(__dirname));
}
function getNearestPackageJsonDirPath(dirPath) {
if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, "package.json"))) {
return dirPath;
}
return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, ".."));
}
//# sourceMappingURL=getThisCodebaseRootDirPath.js.map
/***/ }),
/***/ 64795:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "K": () => (/* binding */ readThisNpmPackageVersion)
/* harmony export */ });
/* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(58822);
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(29041);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(57147);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__nccwpck_require__.n(fs__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
let cache = undefined;
function readThisNpmPackageVersion() {
if (cache !== undefined) {
return cache;
}
const version = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_2__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getThisCodebaseRootDirPath */ .e)(), "package.json"))
.toString("utf8"))["version"];
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_1__/* .assert */ .h)(typeof version === "string");
cache = version;
return version;
}
//# sourceMappingURL=readThisNpmPackageVersion.js.map
/***/ }),
/***/ 99151:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
/* eslint-disable no-control-regex */
// this is a modified version of https://github.com/chalk/ansi-regex (MIT License)
const ANSI_REGEX = /[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g;
const hasColor = () => {
if (typeof process !== 'undefined') {
return process.env.FORCE_COLOR !== '0';
}
return false;
};
const create = () => {
const colors = {
enabled: hasColor(),
visible: true,
styles: {},
keys: {}
};
const ansi = style => {
let open = style.open = `\u001b[${style.codes[0]}m`;
let close = style.close = `\u001b[${style.codes[1]}m`;
let regex = style.regex = new RegExp(`\\u001b\\[${style.codes[1]}m`, 'g');
style.wrap = (input, newline) => {
if (input.includes(close)) input = input.replace(regex, close + open);
let output = open + input + close;
// see https://github.com/chalk/chalk/pull/92, thanks to the
// chalk contributors for this fix. However, we've confirmed that
// this issue is also present in Windows terminals
return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
};
return style;
};
const wrap = (style, input, newline) => {
return typeof style === 'function' ? style(input) : style.wrap(input, newline);
};
const style = (input, stack) => {
if (input === '' || input == null) return '';
if (colors.enabled === false) return input;
if (colors.visible === false) return '';
let str = '' + input;
let nl = str.includes('\n');
let n = stack.length;
if (n > 0 && stack.includes('unstyle')) {
stack = [...new Set(['unstyle', ...stack])].reverse();
}
while (n-- > 0) str = wrap(colors.styles[stack[n]], str, nl);
return str;
};
const define = (name, codes, type) => {
colors.styles[name] = ansi({ name, codes });
let keys = colors.keys[type] || (colors.keys[type] = []);
keys.push(name);
Reflect.defineProperty(colors, name, {
configurable: true,
enumerable: true,
set(value) {
colors.alias(name, value);
},
get() {
let color = input => style(input, color.stack);
Reflect.setPrototypeOf(color, colors);
color.stack = this.stack ? this.stack.concat(name) : [name];
return color;
}
});
};
define('reset', [0, 0], 'modifier');
define('bold', [1, 22], 'modifier');
define('dim', [2, 22], 'modifier');
define('italic', [3, 23], 'modifier');
define('underline', [4, 24], 'modifier');
define('inverse', [7, 27], 'modifier');
define('hidden', [8, 28], 'modifier');
define('strikethrough', [9, 29], 'modifier');
define('black', [30, 39], 'color');
define('red', [31, 39], 'color');
define('green', [32, 39], 'color');
define('yellow', [33, 39], 'color');
define('blue', [34, 39], 'color');
define('magenta', [35, 39], 'color');
define('cyan', [36, 39], 'color');
define('white', [37, 39], 'color');
define('gray', [90, 39], 'color');
define('grey', [90, 39], 'color');
define('bgBlack', [40, 49], 'bg');
define('bgRed', [41, 49], 'bg');
define('bgGreen', [42, 49], 'bg');
define('bgYellow', [43, 49], 'bg');
define('bgBlue', [44, 49], 'bg');
define('bgMagenta', [45, 49], 'bg');
define('bgCyan', [46, 49], 'bg');
define('bgWhite', [47, 49], 'bg');
define('blackBright', [90, 39], 'bright');
define('redBright', [91, 39], 'bright');
define('greenBright', [92, 39], 'bright');
define('yellowBright', [93, 39], 'bright');
define('blueBright', [94, 39], 'bright');
define('magentaBright', [95, 39], 'bright');
define('cyanBright', [96, 39], 'bright');
define('whiteB