@redhat-cloud-services/frontend-components-config-utilities 1.5.23 → 1.5.25
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/chunk-mapper.js +45 -21
- package/cookieTransform.js +3 -2
- package/package.json +1 -1
package/chunk-mapper.js
CHANGED
|
@@ -1,35 +1,59 @@
|
|
|
1
|
+
const hotChunkRegex = RegExp('\\.hot-update\\.js$');
|
|
1
2
|
class ChunkMapper {
|
|
2
3
|
constructor(options) {
|
|
4
|
+
const { _unstableHotReload, ...rest } = options;
|
|
3
5
|
this.config = {};
|
|
4
|
-
this.options =
|
|
6
|
+
this.options = rest || {};
|
|
7
|
+
this._unstableHotReload = _unstableHotReload;
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
apply(compiler) {
|
|
8
11
|
compiler.hooks.emit.tap('ChunkMapper', (compilation) => {
|
|
9
12
|
const prefix = this.options.prefix || (RegExp('^/.*/$').test(compiler.options.output.publicPath) ? compiler.options.output.publicPath : '/');
|
|
10
|
-
|
|
13
|
+
if (this._unstableHotReload) {
|
|
11
14
|
const modules = Array.isArray(this.options.modules) ? this.options.modules : [this.options.modules];
|
|
12
|
-
if
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return !RegExp('\\.hot-update\\.js$').test(file);
|
|
22
|
-
}
|
|
15
|
+
// TODO: Investigate if it is possible we could use the same script for normal builds
|
|
16
|
+
const hotEntries = Array.from(compilation.chunks)
|
|
17
|
+
.filter(({ name, runtime }) => !!modules.find((moduleName) => moduleName === name) || name === runtime)
|
|
18
|
+
.map(({ files }) =>
|
|
19
|
+
Array.from(files)
|
|
20
|
+
.filter((file) => !hotChunkRegex.test(file))
|
|
21
|
+
.map((file) => `${prefix}${file}`)
|
|
22
|
+
)
|
|
23
|
+
.flat();
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
:
|
|
28
|
-
|
|
29
|
-
}),
|
|
25
|
+
modules.forEach((name) => {
|
|
26
|
+
this.config = {
|
|
27
|
+
[name]: {
|
|
28
|
+
entry: hotEntries,
|
|
29
|
+
},
|
|
30
30
|
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
compilation.chunks.forEach(({ name, files, runtime }) => {
|
|
34
|
+
const modules = Array.isArray(this.options.modules) ? this.options.modules : [this.options.modules];
|
|
35
|
+
if (modules.find((oneEntry) => RegExp(`${oneEntry}$`).test(runtime))) {
|
|
36
|
+
this.config[runtime] = {
|
|
37
|
+
...(this.config[runtime] || {}),
|
|
38
|
+
...(name === runtime
|
|
39
|
+
? {
|
|
40
|
+
entry: Array.from(files)
|
|
41
|
+
.map((item) => `${prefix}${item}`)
|
|
42
|
+
.filter((file, _index, array) => {
|
|
43
|
+
if (array.find((item) => !hotChunkRegex.test(item))) {
|
|
44
|
+
return !hotChunkRegex.test(file);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
}),
|
|
49
|
+
}
|
|
50
|
+
: {
|
|
51
|
+
modules: [...(this.config[runtime].modules || []), ...Array.from(files).map((item) => `${prefix}${item}`)],
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
33
57
|
|
|
34
58
|
compilation.assets['fed-mods.json'] = {
|
|
35
59
|
source: () => JSON.stringify(this.config, null, 4),
|
package/cookieTransform.js
CHANGED
|
@@ -13,8 +13,9 @@ const defaultEntitlements = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
function cookieTransform(proxyReq, req, _res, { entitlements = defaultEntitlements, user, internal, identity: customIdentity }) {
|
|
16
|
-
const cookie = req.headers
|
|
17
|
-
const match = cookie
|
|
16
|
+
const { cookie, authorization } = req.headers;
|
|
17
|
+
const match = cookie?.match(/cs_jwt=([^;]+)/) || authorization?.match(/^Bearer (.*)$/);
|
|
18
|
+
|
|
18
19
|
if (match) {
|
|
19
20
|
const cs_jwt = match[1];
|
|
20
21
|
const { payload } = jws.decode(cs_jwt);
|
package/package.json
CHANGED