keycloakify 6.0.0 → 6.0.3
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 +1 -1
- package/bin/keycloakify/BuildOptions.d.ts +2 -2
- package/bin/keycloakify/BuildOptions.js +5 -5
- package/bin/keycloakify/BuildOptions.js.map +1 -1
- package/bin/keycloakify/generateFtl/generateFtl.d.ts +2 -2
- package/bin/keycloakify/generateFtl/generateFtl.js +1 -1
- package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
- package/bin/keycloakify/generateKeycloakThemeResources.d.ts +2 -2
- package/bin/keycloakify/generateKeycloakThemeResources.js +1 -1
- package/bin/keycloakify/generateKeycloakThemeResources.js.map +1 -1
- package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.js +3 -3
- package/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.js.map +1 -1
- package/bin/tsconfig.tsbuildinfo +1 -1
- package/lib/i18n/index.js +0 -7
- package/lib/i18n/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/bin/keycloakify/BuildOptions.ts +8 -8
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +3 -3
- package/src/bin/keycloakify/generateKeycloakThemeResources.ts +3 -3
- package/src/bin/keycloakify/replacers/replaceImportsFromStaticInJsCode.ts +3 -3
- package/src/lib/i18n/index.tsx +0 -10
- package/src/test/bin/replaceImportFromStatic.ts +4 -4
package/package.json
CHANGED
@@ -11,7 +11,7 @@ type ParsedPackageJson = {
|
|
11
11
|
keycloakify?: {
|
12
12
|
extraPages?: string[];
|
13
13
|
extraThemeProperties?: string[];
|
14
|
-
|
14
|
+
areAppAndKeycloakServerSharingSameDomain?: boolean;
|
15
15
|
};
|
16
16
|
};
|
17
17
|
|
@@ -23,7 +23,7 @@ const zParsedPackageJson = z.object({
|
|
23
23
|
.object({
|
24
24
|
"extraPages": z.array(z.string()).optional(),
|
25
25
|
"extraThemeProperties": z.array(z.string()).optional(),
|
26
|
-
"
|
26
|
+
"areAppAndKeycloakServerSharingSameDomain": z.boolean().optional()
|
27
27
|
})
|
28
28
|
.optional()
|
29
29
|
});
|
@@ -56,11 +56,11 @@ export namespace BuildOptions {
|
|
56
56
|
};
|
57
57
|
|
58
58
|
export type SameDomain = CommonExternalAssets & {
|
59
|
-
|
59
|
+
areAppAndKeycloakServerSharingSameDomain: true;
|
60
60
|
};
|
61
61
|
|
62
62
|
export type DifferentDomains = CommonExternalAssets & {
|
63
|
-
|
63
|
+
areAppAndKeycloakServerSharingSameDomain: false;
|
64
64
|
urlOrigin: string;
|
65
65
|
urlPathname: string | undefined;
|
66
66
|
};
|
@@ -140,10 +140,10 @@ export function readBuildOptions(params: {
|
|
140
140
|
"isStandalone": false
|
141
141
|
});
|
142
142
|
|
143
|
-
if (parsedPackageJson.keycloakify?.
|
143
|
+
if (parsedPackageJson.keycloakify?.areAppAndKeycloakServerSharingSameDomain) {
|
144
144
|
return id<BuildOptions.ExternalAssets.SameDomain>({
|
145
145
|
...commonExternalAssets,
|
146
|
-
"
|
146
|
+
"areAppAndKeycloakServerSharingSameDomain": true
|
147
147
|
});
|
148
148
|
} else {
|
149
149
|
assert(
|
@@ -155,14 +155,14 @@ export function readBuildOptions(params: {
|
|
155
155
|
"public/CNAME file.",
|
156
156
|
"Alternatively, if your app and the Keycloak server are on the same domain, ",
|
157
157
|
"eg https://example.com is your app and https://example.com/auth is the keycloak",
|
158
|
-
'admin UI, you can set "keycloakify": { "
|
158
|
+
'admin UI, you can set "keycloakify": { "areAppAndKeycloakServerSharingSameDomain": true }',
|
159
159
|
"in your package.json"
|
160
160
|
].join(" ")
|
161
161
|
);
|
162
162
|
|
163
163
|
return id<BuildOptions.ExternalAssets.DifferentDomains>({
|
164
164
|
...commonExternalAssets,
|
165
|
-
"
|
165
|
+
"areAppAndKeycloakServerSharingSameDomain": false,
|
166
166
|
"urlOrigin": url.origin,
|
167
167
|
"urlPathname": url.pathname
|
168
168
|
});
|
@@ -46,11 +46,11 @@ export namespace BuildOptionsLike {
|
|
46
46
|
};
|
47
47
|
|
48
48
|
export type SameDomain = CommonExternalAssets & {
|
49
|
-
|
49
|
+
areAppAndKeycloakServerSharingSameDomain: true;
|
50
50
|
};
|
51
51
|
|
52
52
|
export type DifferentDomains = CommonExternalAssets & {
|
53
|
-
|
53
|
+
areAppAndKeycloakServerSharingSameDomain: false;
|
54
54
|
urlOrigin: string;
|
55
55
|
urlPathname: string | undefined;
|
56
56
|
};
|
@@ -76,7 +76,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|
76
76
|
const $ = cheerio.load(indexHtmlCode);
|
77
77
|
|
78
78
|
fix_imports_statements: {
|
79
|
-
if (!buildOptions.isStandalone && buildOptions.
|
79
|
+
if (!buildOptions.isStandalone && buildOptions.areAppAndKeycloakServerSharingSameDomain) {
|
80
80
|
break fix_imports_statements;
|
81
81
|
}
|
82
82
|
|
@@ -34,11 +34,11 @@ export namespace BuildOptionsLike {
|
|
34
34
|
};
|
35
35
|
|
36
36
|
export type SameDomain = CommonExternalAssets & {
|
37
|
-
|
37
|
+
areAppAndKeycloakServerSharingSameDomain: true;
|
38
38
|
};
|
39
39
|
|
40
40
|
export type DifferentDomains = CommonExternalAssets & {
|
41
|
-
|
41
|
+
areAppAndKeycloakServerSharingSameDomain: false;
|
42
42
|
urlOrigin: string;
|
43
43
|
urlPathname: string | undefined;
|
44
44
|
};
|
@@ -97,7 +97,7 @@ export function generateKeycloakThemeResources(params: {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
if (/\.js?$/i.test(filePath)) {
|
100
|
-
if (!buildOptions.isStandalone && buildOptions.
|
100
|
+
if (!buildOptions.isStandalone && buildOptions.areAppAndKeycloakServerSharingSameDomain) {
|
101
101
|
return undefined;
|
102
102
|
}
|
103
103
|
|
@@ -57,7 +57,7 @@ export function replaceImportsFromStaticInJsCode(params: { jsCode: string; build
|
|
57
57
|
: `
|
58
58
|
var p= "";
|
59
59
|
Object.defineProperty(${n}, "p", {
|
60
|
-
get: function() { return "${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}" : p; },
|
60
|
+
get: function() { return "${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}/" : p; },
|
61
61
|
set: function (value){ p = value;}
|
62
62
|
});
|
63
63
|
`
|
@@ -73,13 +73,13 @@ export function replaceImportsFromStaticInJsCode(params: { jsCode: string; build
|
|
73
73
|
.replace(/([a-zA-Z]+\.[a-zA-Z]+)\+"static\//g, (...[, group]) =>
|
74
74
|
buildOptions.isStandalone
|
75
75
|
? `window.${ftlValuesGlobalName}.url.resourcesPath + "/build/static/`
|
76
|
-
: `("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}" : ${group}) + "static/`
|
76
|
+
: `("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}/" : ${group}) + "static/`
|
77
77
|
)
|
78
78
|
//TODO: Write a test case for this
|
79
79
|
.replace(/".chunk.css",([a-zA-Z])+=([a-zA-Z]+\.[a-zA-Z]+)\+([a-zA-Z]+),/, (...[, group1, group2, group3]) =>
|
80
80
|
buildOptions.isStandalone
|
81
81
|
? `".chunk.css",${group1} = window.${ftlValuesGlobalName}.url.resourcesPath + "/build/" + ${group3},`
|
82
|
-
: `".chunk.css",${group1} = ("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}" : ${group2}) + ${group3},`
|
82
|
+
: `".chunk.css",${group1} = ("${ftlValuesGlobalName}" in window ? "${buildOptions.urlOrigin}/" : ${group2}) + ${group3},`
|
83
83
|
);
|
84
84
|
|
85
85
|
return { fixedJsCode };
|
package/src/lib/i18n/index.tsx
CHANGED
@@ -83,8 +83,6 @@ export function __unsafe_useI18n<ExtraMessageKey extends string = never>(params:
|
|
83
83
|
return;
|
84
84
|
}
|
85
85
|
|
86
|
-
let isMounted = true;
|
87
|
-
|
88
86
|
refHasStartedFetching.current = true;
|
89
87
|
|
90
88
|
(async () => {
|
@@ -144,10 +142,6 @@ export function __unsafe_useI18n<ExtraMessageKey extends string = never>(params:
|
|
144
142
|
})()
|
145
143
|
]).then(modules => modules.map(module => module.default));
|
146
144
|
|
147
|
-
if (!isMounted) {
|
148
|
-
return;
|
149
|
-
}
|
150
|
-
|
151
145
|
setI18n({
|
152
146
|
...createI18nTranslationFunctions({
|
153
147
|
"fallbackMessages": {
|
@@ -180,10 +174,6 @@ export function __unsafe_useI18n<ExtraMessageKey extends string = never>(params:
|
|
180
174
|
)
|
181
175
|
});
|
182
176
|
})();
|
183
|
-
|
184
|
-
return () => {
|
185
|
-
isMounted = false;
|
186
|
-
};
|
187
177
|
}, []);
|
188
178
|
|
189
179
|
return i18n ?? null;
|
@@ -103,13 +103,13 @@ import { assetIsSameCode } from "../tools/assertIsSameCode";
|
|
103
103
|
|
104
104
|
const fixedJsCodeExpected = `
|
105
105
|
function f() {
|
106
|
-
return ("kcContext" in window ? "https://demo-app.keycloakify.dev" : a.p) + "static/js/" + ({}[e] || e) + "." + {
|
106
|
+
return ("kcContext" in window ? "https://demo-app.keycloakify.dev/" : a.p) + "static/js/" + ({}[e] || e) + "." + {
|
107
107
|
3: "0664cdc0"
|
108
108
|
}[e] + ".chunk.js"
|
109
109
|
}
|
110
110
|
|
111
111
|
function sameAsF() {
|
112
|
-
return ("kcContext" in window ? "https://demo-app.keycloakify.dev" : a.p) + "static/js/" + ({}[e] || e) + "." + {
|
112
|
+
return ("kcContext" in window ? "https://demo-app.keycloakify.dev/" : a.p) + "static/js/" + ({}[e] || e) + "." + {
|
113
113
|
3: "0664cdc0"
|
114
114
|
}[e] + ".chunk.js"
|
115
115
|
}
|
@@ -119,7 +119,7 @@ import { assetIsSameCode } from "../tools/assertIsSameCode";
|
|
119
119
|
if( pd === undefined || pd.configurable ){
|
120
120
|
var p= "";
|
121
121
|
Object.defineProperty(__webpack_require__, "p", {
|
122
|
-
get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev" : p; },
|
122
|
+
get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev/" : p; },
|
123
123
|
set: function (value){ p = value; }
|
124
124
|
});
|
125
125
|
}
|
@@ -137,7 +137,7 @@ import { assetIsSameCode } from "../tools/assertIsSameCode";
|
|
137
137
|
if( pd === undefined || pd.configurable ){
|
138
138
|
var p= "";
|
139
139
|
Object.defineProperty(t, "p", {
|
140
|
-
get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev" : p; },
|
140
|
+
get: function() { return "kcContext" in window ? "https://demo-app.keycloakify.dev/" : p; },
|
141
141
|
set: function (value){ p = value; }
|
142
142
|
});
|
143
143
|
}
|