UNPKG

keycloakify

Version:

Framework to create custom Keycloak UIs

1,159 lines (1,077 loc) 341 kB
/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 713: /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { "use strict"; // ESM COMPAT FLAG __nccwpck_require__.r(__webpack_exports__); // EXPORTS __nccwpck_require__.d(__webpack_exports__, { "command": () => (/* binding */ command) }); // EXTERNAL MODULE: ./dist/bin/shared/customHandler_delegate.js + 1 modules var customHandler_delegate = __nccwpck_require__(138); // EXTERNAL MODULE: external "path" var external_path_ = __nccwpck_require__(17); // EXTERNAL MODULE: ./dist/bin/shared/constants.js var constants = __nccwpck_require__(173); // EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js var readThisNpmPackageVersion = __nccwpck_require__(795); // EXTERNAL MODULE: external "fs" var external_fs_ = __nccwpck_require__(147); // EXTERNAL MODULE: ./dist/bin/tools/SemVer.js var SemVer = __nccwpck_require__(171); ;// CONCATENATED MODULE: ./dist/bin/tools/fs.rmSync.js /** * Polyfill of fs.rmSync(dirPath, { "recursive": true }) * For older version of Node */ function rmSync(dirPath, options) { if (SemVer/* SemVer.compare */.h.compare(SemVer/* SemVer.parse */.h.parse(process.version), SemVer/* SemVer.parse */.h.parse("14.14.0")) > 0) { external_fs_.rmSync(dirPath, options); return; } const { force = true } = options; if (force && !external_fs_.existsSync(dirPath)) { return; } const removeDir_rec = (dirPath) => external_fs_.readdirSync(dirPath).forEach(basename => { const fileOrDirPath = (0,external_path_.join)(dirPath, basename); if (external_fs_.lstatSync(fileOrDirPath).isDirectory()) { removeDir_rec(fileOrDirPath); return; } else { external_fs_.unlinkSync(fileOrDirPath); } }); removeDir_rec(dirPath); } //# sourceMappingURL=fs.rmSync.js.map // EXTERNAL MODULE: ./dist/bin/tools/crawl.js var crawl = __nccwpck_require__(36); ;// CONCATENATED MODULE: ./dist/bin/tools/transformCodebase.js /** * Apply a transformation function to every file of directory * If source and destination are the same this function can be used to apply the transformation in place * like filtering out some files or modifying them. * */ function transformCodebase(params) { const { srcDirPath, transformSourceCode } = params; const isTargetSameAsSource = external_path_.relative(srcDirPath, params.destDirPath) === ""; const destDirPath = isTargetSameAsSource ? external_path_.join(srcDirPath, "..", "tmp_xOsPdkPsTdzPs34sOkHs") : params.destDirPath; external_fs_.mkdirSync(destDirPath, { recursive: true }); for (const fileRelativePath of (0,crawl/* crawl */.J)({ dirPath: srcDirPath, returnedPathsType: "relative to dirPath" })) { const filePath = external_path_.join(srcDirPath, fileRelativePath); const destFilePath = external_path_.join(destDirPath, fileRelativePath); // NOTE: Optimization, if we don't need to transform the file, just copy // it using the lower level implementation. if (transformSourceCode === undefined) { external_fs_.mkdirSync(external_path_.dirname(destFilePath), { recursive: true }); external_fs_.copyFileSync(filePath, destFilePath); continue; } const transformSourceCodeResult = transformSourceCode({ sourceCode: external_fs_.readFileSync(filePath), filePath, fileRelativePath }); if (transformSourceCodeResult === undefined) { continue; } external_fs_.mkdirSync(external_path_.dirname(destFilePath), { recursive: true }); const { newFileName, modifiedSourceCode } = transformSourceCodeResult; external_fs_.writeFileSync(external_path_.join(external_path_.dirname(destFilePath), newFileName !== null && newFileName !== void 0 ? newFileName : external_path_.basename(destFilePath)), modifiedSourceCode); } if (isTargetSameAsSource) { rmSync(srcDirPath, { recursive: true }); external_fs_.renameSync(destDirPath, srcDirPath); } } //# sourceMappingURL=transformCodebase.js.map // EXTERNAL MODULE: ./dist/bin/tools/getThisCodebaseRootDirPath.js var getThisCodebaseRootDirPath = __nccwpck_require__(822); ;// CONCATENATED MODULE: ./dist/bin/copy-keycloak-resources-to-public.js async function command(params) { const { buildContext } = params; const { hasBeenHandled } = await (0,customHandler_delegate/* maybeDelegateCommandToCustomHandler */.q)({ commandName: "copy-keycloak-resources-to-public", buildContext }); if (hasBeenHandled) { return; } const destDirPath = (0,external_path_.join)(buildContext.publicDirPath, constants.WELL_KNOWN_DIRECTORY_BASE_NAME.KEYCLOAKIFY_DEV_RESOURCES); const keycloakifyBuildinfoFilePath = (0,external_path_.join)(destDirPath, "keycloakify.buildinfo"); const keycloakifyBuildinfoRaw = JSON.stringify({ keycloakifyVersion: (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)() }, null, 2); skip_if_already_done: { if (!external_fs_.existsSync(keycloakifyBuildinfoFilePath)) { break skip_if_already_done; } const keycloakifyBuildinfoRaw_previousRun = external_fs_.readFileSync(keycloakifyBuildinfoFilePath) .toString("utf8"); if (keycloakifyBuildinfoRaw_previousRun !== keycloakifyBuildinfoRaw) { break skip_if_already_done; } return; } rmSync(destDirPath, { force: true, recursive: true }); // NOTE: To remove in a while, remove the legacy keycloak-resources directory rmSync((0,external_path_.join)((0,external_path_.dirname)(destDirPath), "keycloak-resources"), { force: true, recursive: true }); rmSync((0,external_path_.join)((0,external_path_.dirname)(destDirPath), ".keycloakify"), { force: true, recursive: true }); external_fs_.mkdirSync(destDirPath, { recursive: true }); external_fs_.writeFileSync((0,external_path_.join)(destDirPath, ".gitignore"), Buffer.from("*", "utf8")); transformCodebase({ srcDirPath: (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "res", "public", constants.WELL_KNOWN_DIRECTORY_BASE_NAME.KEYCLOAKIFY_DEV_RESOURCES), destDirPath }); external_fs_.writeFileSync((0,external_path_.join)(destDirPath, "README.txt"), Buffer.from( // prettier-ignore [ "This directory is only used in dev mode by Keycloakify", "It won't be included in your final build.", "Do not modify anything in this directory.", ].join("\n"))); external_fs_.writeFileSync(keycloakifyBuildinfoFilePath, Buffer.from(keycloakifyBuildinfoRaw, "utf8")); } //# sourceMappingURL=copy-keycloak-resources-to-public.js.map /***/ }), /***/ 250: /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { "use strict"; // ESM COMPAT FLAG __nccwpck_require__.r(__webpack_exports__); // EXPORTS __nccwpck_require__.d(__webpack_exports__, { "getBuildContext": () => (/* binding */ getBuildContext) }); ;// CONCATENATED MODULE: external "url" const external_url_namespaceObject = require("url"); // EXTERNAL MODULE: external "path" var external_path_ = __nccwpck_require__(17); // EXTERNAL MODULE: external "os" var external_os_ = __nccwpck_require__(37); ;// CONCATENATED MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js function getAbsoluteAndInOsFormatPath(params) { const { pathIsh, cwd } = params; let pathOut = pathIsh; pathOut = pathOut.replace(/^['"]/, "").replace(/['"]$/, ""); pathOut = pathOut.replace(/\//g, external_path_.sep); if (pathOut.startsWith("~")) { pathOut = pathOut.replace("~", external_os_.homedir()); } pathOut = pathOut.endsWith(external_path_.sep) ? pathOut.slice(0, -1) : pathOut; if (!(0,external_path_.isAbsolute)(pathOut)) { pathOut = (0,external_path_.join)(cwd, pathOut); } pathOut = (0,external_path_.resolve)(pathOut); return pathOut; } //# sourceMappingURL=getAbsoluteAndInOsFormatPath.js.map // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs var lib = __nccwpck_require__(300); // EXTERNAL MODULE: external "fs" var external_fs_ = __nccwpck_require__(147); // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules var assert = __nccwpck_require__(41); // EXTERNAL MODULE: external "child_process" var external_child_process_ = __nccwpck_require__(81); // EXTERNAL MODULE: ./dist/bin/shared/constants.js var constants = __nccwpck_require__(173); ;// CONCATENATED MODULE: ./node_modules/tsafe/esm/exclude.mjs /** * https://docs.tsafe.dev/exclude * * Return a function to use as Array.prototype.filter argument * to exclude one or many primitive value element from the array. * Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] * Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[] */ function exclude(target) { const test = target instanceof Object ? element => target.indexOf(element) < 0 : element => element !== target; return function (element) { return test(element); }; } //# sourceMappingURL=exclude.mjs.map ;// CONCATENATED MODULE: ./node_modules/tsafe/esm/index.mjs //# sourceMappingURL=index.mjs.map // EXTERNAL MODULE: ./dist/bin/tools/crawl.js var crawl = __nccwpck_require__(36); ;// 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__(469); // EXTERNAL MODULE: ./node_modules/chalk/source/index.js var source = __nccwpck_require__(818); 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(exclude(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(exclude(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 ? getAbsoluteAndInOsFormatPath({ 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, constants.KEYCLOAK_THEME.replace(/-/g, "_") ]) { const split = fileRelativePath.split(themeSrcDirBasename); if (split.length === 2) { return (0,external_path_.join)(srcDirPath, split[0] + themeSrcDirBasename); } } return undefined; }) .filter(exclude(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]: "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), "Seems like the Keycloakify's Vite plugin is not installed."); const resolvedViteConfigStr = output .split(constants.VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.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 getAbsoluteAndInOsFormatPath({ 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_namespaceObject.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 getAbsoluteAndInOsFormatPath({ 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 getAbsoluteAndInOsFormatPath({ 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 getAbsoluteAndInOsFormatPath({ 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 getAbsoluteAndInOsFormatPath({ 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) { getAbsoluteAndInOsFormatPath({ 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 = getAbsoluteAndInOsFormatPath({ 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]; 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: getAbsoluteAndInOsFormatPath({ pathIsh: urlOrPath, cwd: relativePathsCwd }) }; }), realmJsonFilePath: ((_m = buildOptions.startKeycloakOptions) === null || _m === void 0 ? void 0 : _m.realmJsonFilePath) === undefined ? undefined : getAbsoluteAndInOsFormatPath({ 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"; __nccwpck_require__.r(__webpack_exports__); /* harmony export */ __nccwpck_require__.d(__webpack_exports__, { /* harmony export */ "ACCOUNT_THEME_PAGE_IDS": () => (/* binding */ ACCOUNT_THEME_PAGE_IDS), /* harmony export */ "BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME": () => (/* binding */ BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME), /* harmony export */ "CONTAINER_NAME": () => (/* binding */ CONTAINER_NAME), /* harmony export */ "CUSTOM_HANDLER_ENV_NAMES": () => (/* binding */ CUSTOM_HANDLER_ENV_NAMES), /* harmony export */ "FALLBACK_LANGUAGE_TAG": () => (/* binding */ FALLBACK_LANGUAGE_TAG), /* harmony export */ "KEYCLOAKIFY_LOGGING_VERSION": () => (/* binding */ KEYCLOAKIFY_LOGGING_VERSION), /* harmony export */ "KEYCLOAKIFY_LOGIN_JAR_BASENAME": () => (/* binding */ KEYCLOAKIFY_LOGIN_JAR_BASENAME), /* harmony export */ "KEYCLOAKIFY_SPA_DEV_SERVER_PORT": () => (/* binding */ KEYCLOAKIFY_SPA_DEV_SERVER_PORT), /* harmony export */ "KEYCLOAK_THEME": () => (/* binding */ KEYCLOAK_THEME), /* harmony export */ "LOGIN_THEME_PAGE_IDS": () => (/* binding */ LOGIN_THEME_PAGE_IDS), /* harmony export */ "TEST_APP_URL": () => (/* binding */ TEST_APP_URL), /* harmony export */ "THEME_TYPES": () => (/* binding */ THEME_TYPES), /* harmony export */ "VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES": () => (/* binding */ VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES), /* harmony export */ "WELL_KNOWN_DIRECTORY_BASE_NAME": () => (/* binding */ WELL_KNOWN_DIRECTORY_BASE_NAME) /* harmony export */ }); 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 /***/ }), /***/ 138: /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { "use strict"; // EXPORTS __nccwpck_require__.d(__webpack_exports__, { "q": () => (/* binding */ maybeDelegateCommandToCustomHandler) }); // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules var esm_assert = __nccwpck_require__(41); // EXTERNAL MODULE: ./dist/bin/shared/constants.js var constants = __nccwpck_require__(173); ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js const BIN_NAME = "_keycloakify-custom-handler"; const NOT_IMPLEMENTED_EXIT_CODE = 78; function readParams(params) { const { apiVersion } = params; assert(apiVersion === "v1"); const commandName = (() => { const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME]; assert(envValue !== undefined); return envValue; })(); const buildContext = (() => { const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT]; assert(envValue !== undefined); return JSON.parse(envValue); })(); return { commandName, buildContext }; } //# sourceMappingURL=customHandler.js.map // EXTERNAL MODULE: external "child_process" var external_child_process_ = __nccwpck_require__(81); // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js var tools_nodeModulesBinDirPath = __nccwpck_require__(776); // EXTERNAL MODULE: external "fs" var external_fs_ = __nccwpck_require__(147); ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js (0,esm_assert/* assert */.h)(); async function maybeDelegateCommandToCustomHandler(params) { const { commandName, buildContext } = params; const nodeModulesBinDirPath = await (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)({ packageJsonFilePath: buildContext.packageJsonFilePath }); if (!external_fs_.readdirSy