keycloakify 7.13.2 → 7.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/bin/eject-keycloak-page.js +0 -3
- package/bin/eject-keycloak-page.js.map +1 -1
- package/bin/getSrcDirPath.d.ts +1 -2
- package/bin/getSrcDirPath.js +62 -5
- package/bin/getSrcDirPath.js.map +1 -1
- package/bin/initialize-email-theme.js +0 -4
- package/bin/initialize-email-theme.js.map +1 -1
- package/bin/keycloakify/BuildOptions.d.ts +1 -3
- package/bin/keycloakify/BuildOptions.js +1 -3
- package/bin/keycloakify/BuildOptions.js.map +1 -1
- package/bin/keycloakify/generateJavaStackFiles.d.ts +1 -1
- package/bin/keycloakify/generateTheme/generateTheme.d.ts +2 -4
- package/bin/keycloakify/generateTheme/generateTheme.js +28 -35
- package/bin/keycloakify/generateTheme/generateTheme.js.map +1 -1
- package/bin/keycloakify/generateTheme/readExtraPageNames.d.ts +5 -0
- package/bin/keycloakify/generateTheme/readExtraPageNames.js +105 -0
- package/bin/keycloakify/generateTheme/readExtraPageNames.js.map +1 -0
- package/bin/keycloakify/generateTheme/readFieldNameUsage.d.ts +3 -2
- package/bin/keycloakify/generateTheme/readFieldNameUsage.js +21 -76
- package/bin/keycloakify/generateTheme/readFieldNameUsage.js.map +1 -1
- package/bin/keycloakify/keycloakify.js +0 -5
- package/bin/keycloakify/keycloakify.js.map +1 -1
- package/bin/keycloakify/parsedPackageJson.d.ts +0 -22
- package/bin/keycloakify/parsedPackageJson.js +0 -3
- package/bin/keycloakify/parsedPackageJson.js.map +1 -1
- package/bin/tools/crawl.d.ts +4 -1
- package/bin/tools/crawl.js +31 -26
- package/bin/tools/crawl.js.map +1 -1
- package/bin/tools/transformCodebase.js +2 -2
- package/bin/tools/transformCodebase.js.map +1 -1
- package/package.json +6 -1
- package/src/bin/eject-keycloak-page.ts +0 -4
- package/src/bin/getSrcDirPath.ts +20 -6
- package/src/bin/initialize-email-theme.ts +0 -6
- package/src/bin/keycloakify/BuildOptions.ts +2 -16
- package/src/bin/keycloakify/generateJavaStackFiles.ts +1 -1
- package/src/bin/keycloakify/generateTheme/generateTheme.ts +26 -36
- package/src/bin/keycloakify/generateTheme/readExtraPageNames.ts +38 -0
- package/src/bin/keycloakify/generateTheme/readFieldNameUsage.ts +6 -67
- package/src/bin/keycloakify/keycloakify.ts +0 -6
- package/src/bin/keycloakify/parsedPackageJson.ts +0 -7
- package/src/bin/tools/crawl.ts +23 -18
- package/src/bin/tools/transformCodebase.ts +2 -2
@@ -0,0 +1,38 @@
|
|
1
|
+
import { crawl } from "../../tools/crawl";
|
2
|
+
import { type ThemeType, accountThemePageIds, loginThemePageIds } from "../generateFtl";
|
3
|
+
import { id } from "tsafe/id";
|
4
|
+
import { removeDuplicates } from "evt/tools/reducers/removeDuplicates";
|
5
|
+
import * as fs from "fs";
|
6
|
+
import { join as pathJoin } from "path";
|
7
|
+
|
8
|
+
export function readExtraPagesNames(params: { themeSrcDirPath: string; themeType: ThemeType }): string[] {
|
9
|
+
const { themeSrcDirPath, themeType } = params;
|
10
|
+
|
11
|
+
const filePaths = crawl({
|
12
|
+
"dirPath": pathJoin(themeSrcDirPath, themeType),
|
13
|
+
"returnedPathsType": "absolute"
|
14
|
+
}).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
|
15
|
+
|
16
|
+
const candidateFilePaths = filePaths.filter(filePath => /kcContext\.[^.]+$/.test(filePath));
|
17
|
+
|
18
|
+
if (candidateFilePaths.length === 0) {
|
19
|
+
candidateFilePaths.push(...filePaths);
|
20
|
+
}
|
21
|
+
|
22
|
+
const extraPages: string[] = [];
|
23
|
+
|
24
|
+
for (const candidateFilPath of candidateFilePaths) {
|
25
|
+
const rawSourceFile = fs.readFileSync(candidateFilPath).toString("utf8");
|
26
|
+
|
27
|
+
extraPages.push(...Array.from(rawSourceFile.matchAll(/["']?pageId["']?\s*:\s*["']([^.]+.ftl)["']/g), m => m[1]));
|
28
|
+
}
|
29
|
+
|
30
|
+
return extraPages.reduce(...removeDuplicates<string>()).filter(pageId => {
|
31
|
+
switch (themeType) {
|
32
|
+
case "account":
|
33
|
+
return !id<readonly string[]>(accountThemePageIds).includes(pageId);
|
34
|
+
case "login":
|
35
|
+
return !id<readonly string[]>(loginThemePageIds).includes(pageId);
|
36
|
+
}
|
37
|
+
});
|
38
|
+
}
|
@@ -5,77 +5,16 @@ import * as fs from "fs";
|
|
5
5
|
import type { ThemeType } from "../generateFtl";
|
6
6
|
import { exclude } from "tsafe/exclude";
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
themeSrcDirPath: string | undefined;
|
11
|
-
themeType: ThemeType | "email";
|
12
|
-
}): string[] {
|
8
|
+
/** Assumes the theme type exists */
|
9
|
+
export function readFieldNameUsage(params: { keycloakifySrcDirPath: string; themeSrcDirPath: string; themeType: ThemeType }): string[] {
|
13
10
|
const { keycloakifySrcDirPath, themeSrcDirPath, themeType } = params;
|
14
11
|
|
15
12
|
const fieldNames: string[] = [];
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"global",
|
22
|
-
"userLabel",
|
23
|
-
"username",
|
24
|
-
"email",
|
25
|
-
"firstName",
|
26
|
-
"lastName",
|
27
|
-
"password",
|
28
|
-
"password-confirm",
|
29
|
-
"totp",
|
30
|
-
"totpSecret",
|
31
|
-
"SAMLRequest",
|
32
|
-
"SAMLResponse",
|
33
|
-
"relayState",
|
34
|
-
"device_user_code",
|
35
|
-
"code",
|
36
|
-
"password-new",
|
37
|
-
"rememberMe",
|
38
|
-
"login",
|
39
|
-
"authenticationExecution",
|
40
|
-
"cancel-aia",
|
41
|
-
"clientDataJSON",
|
42
|
-
"authenticatorData",
|
43
|
-
"signature",
|
44
|
-
"credentialId",
|
45
|
-
"userHandle",
|
46
|
-
"error",
|
47
|
-
"authn_use_chk",
|
48
|
-
"authenticationExecution",
|
49
|
-
"isSetRetry",
|
50
|
-
"try-again",
|
51
|
-
"attestationObject",
|
52
|
-
"publicKeyCredentialId",
|
53
|
-
"authenticatorLabel"
|
54
|
-
]
|
55
|
-
);
|
56
|
-
}
|
57
|
-
|
58
|
-
for (const srcDirPath of (
|
59
|
-
[
|
60
|
-
pathJoin(keycloakifySrcDirPath, themeType),
|
61
|
-
(() => {
|
62
|
-
if (themeSrcDirPath === undefined) {
|
63
|
-
return undefined;
|
64
|
-
}
|
65
|
-
|
66
|
-
const srcDirPath = pathJoin(themeSrcDirPath, themeType);
|
67
|
-
|
68
|
-
if (!fs.existsSync(srcDirPath)) {
|
69
|
-
return undefined;
|
70
|
-
}
|
71
|
-
|
72
|
-
return srcDirPath;
|
73
|
-
})()
|
74
|
-
] as const
|
75
|
-
).filter(exclude(undefined))) {
|
76
|
-
const filePaths = crawl(srcDirPath)
|
77
|
-
.filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath))
|
78
|
-
.map(filePath => pathJoin(srcDirPath, filePath));
|
14
|
+
for (const srcDirPath of ([pathJoin(keycloakifySrcDirPath, themeType), pathJoin(themeSrcDirPath, themeType)] as const).filter(
|
15
|
+
exclude(undefined)
|
16
|
+
)) {
|
17
|
+
const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
|
79
18
|
|
80
19
|
for (const filePath of filePaths) {
|
81
20
|
const rawSourceFile = fs.readFileSync(filePath).toString("utf8");
|
@@ -57,12 +57,6 @@ export async function main() {
|
|
57
57
|
"email": false
|
58
58
|
};
|
59
59
|
|
60
|
-
if (themeSrcDirPath === undefined) {
|
61
|
-
implementedThemeTypes["login"] = true;
|
62
|
-
implementedThemeTypes["account"] = true;
|
63
|
-
return implementedThemeTypes;
|
64
|
-
}
|
65
|
-
|
66
60
|
for (const themeType of objectKeys(implementedThemeTypes)) {
|
67
61
|
if (!fs.existsSync(pathJoin(themeSrcDirPath, themeType))) {
|
68
62
|
continue;
|
@@ -11,10 +11,6 @@ export type ParsedPackageJson = {
|
|
11
11
|
version?: string;
|
12
12
|
homepage?: string;
|
13
13
|
keycloakify?: {
|
14
|
-
/** @deprecated: use extraLoginPages instead */
|
15
|
-
extraPages?: string[];
|
16
|
-
extraLoginPages?: string[];
|
17
|
-
extraAccountPages?: string[];
|
18
14
|
extraThemeProperties?: string[];
|
19
15
|
areAppAndKeycloakServerSharingSameDomain?: boolean;
|
20
16
|
artifactId?: string;
|
@@ -34,9 +30,6 @@ export const zParsedPackageJson = z.object({
|
|
34
30
|
"homepage": z.string().optional(),
|
35
31
|
"keycloakify": z
|
36
32
|
.object({
|
37
|
-
"extraPages": z.array(z.string()).optional(),
|
38
|
-
"extraLoginPages": z.array(z.string()).optional(),
|
39
|
-
"extraAccountPages": z.array(z.string()).optional(),
|
40
33
|
"extraThemeProperties": z.array(z.string()).optional(),
|
41
34
|
"areAppAndKeycloakServerSharingSameDomain": z.boolean().optional(),
|
42
35
|
"artifactId": z.string().optional(),
|
package/src/bin/tools/crawl.ts
CHANGED
@@ -1,27 +1,32 @@
|
|
1
1
|
import * as fs from "fs";
|
2
2
|
import * as path from "path";
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
for (const file_name of fs.readdirSync(dir_path)) {
|
8
|
-
const file_path = path.join(dir_path, file_name);
|
9
|
-
|
10
|
-
if (fs.lstatSync(file_path).isDirectory()) {
|
11
|
-
crawlRec(file_path, paths);
|
4
|
+
const crawlRec = (dir_path: string, paths: string[]) => {
|
5
|
+
for (const file_name of fs.readdirSync(dir_path)) {
|
6
|
+
const file_path = path.join(dir_path, file_name);
|
12
7
|
|
13
|
-
|
14
|
-
|
8
|
+
if (fs.lstatSync(file_path).isDirectory()) {
|
9
|
+
crawlRec(file_path, paths);
|
15
10
|
|
16
|
-
|
11
|
+
continue;
|
17
12
|
}
|
18
|
-
};
|
19
13
|
|
20
|
-
|
21
|
-
|
14
|
+
paths.push(file_path);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
|
18
|
+
/** List all files in a given directory return paths relative to the dir_path */
|
19
|
+
export function crawl(params: { dirPath: string; returnedPathsType: "absolute" | "relative to dirPath" }): string[] {
|
20
|
+
const { dirPath, returnedPathsType } = params;
|
21
|
+
|
22
|
+
const filePaths: string[] = [];
|
22
23
|
|
23
|
-
|
24
|
+
crawlRec(dirPath, filePaths);
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
switch (returnedPathsType) {
|
27
|
+
case "absolute":
|
28
|
+
return filePaths;
|
29
|
+
case "relative to dirPath":
|
30
|
+
return filePaths.map(filePath => path.relative(dirPath, filePath));
|
31
|
+
}
|
32
|
+
}
|
@@ -20,12 +20,12 @@ export function transformCodebase(params: { srcDirPath: string; destDirPath: str
|
|
20
20
|
}))
|
21
21
|
} = params;
|
22
22
|
|
23
|
-
for (const file_relative_path of crawl(srcDirPath)) {
|
23
|
+
for (const file_relative_path of crawl({ "dirPath": srcDirPath, "returnedPathsType": "relative to dirPath" })) {
|
24
24
|
const filePath = path.join(srcDirPath, file_relative_path);
|
25
25
|
|
26
26
|
const transformSourceCodeResult = transformSourceCode({
|
27
27
|
"sourceCode": fs.readFileSync(filePath),
|
28
|
-
|
28
|
+
filePath
|
29
29
|
});
|
30
30
|
|
31
31
|
if (transformSourceCodeResult === undefined) {
|