@elliemae/pui-cli 8.41.5 → 8.42.0-alpha.2
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/dist/cjs/server/certs/uiplatform.p12 +0 -0
- package/dist/cjs/server/csp.js +1 -1
- package/dist/cjs/server/index.js +15 -5
- package/dist/cjs/server/wsServer.js +4 -12
- package/dist/cjs/testing/ExtendedJSDomEnv.cjs +37 -0
- package/dist/cjs/testing/extended/axe-core/getMessageAndPass.js +36 -0
- package/dist/cjs/testing/extended/axe-core/index.js +24 -0
- package/dist/cjs/testing/extended/axe-core/reporter.js +50 -0
- package/dist/cjs/testing/extended/axe-core/shouldIgnoreNodeViolation.js +31 -0
- package/dist/cjs/testing/extended/axe-core/toHaveNoViolations.js +42 -0
- package/dist/cjs/testing/jest.config.cjs +1 -1
- package/dist/cjs/testing/setup-tests.js +2 -2
- package/dist/cjs/webpack/webpack.dev.babel.js +11 -4
- package/dist/cjs/webpack/webpack.prod.babel.js +2 -1
- package/dist/esm/server/certs/uiplatform.p12 +0 -0
- package/dist/esm/server/csp.js +1 -1
- package/dist/esm/server/index.js +16 -6
- package/dist/esm/server/wsServer.js +4 -12
- package/dist/esm/testing/ExtendedJSDomEnv.cjs +37 -0
- package/dist/esm/testing/extended/axe-core/getMessageAndPass.js +16 -0
- package/dist/esm/testing/extended/axe-core/index.js +4 -0
- package/dist/esm/testing/extended/axe-core/reporter.js +30 -0
- package/dist/esm/testing/extended/axe-core/shouldIgnoreNodeViolation.js +11 -0
- package/dist/esm/testing/extended/axe-core/toHaveNoViolations.js +22 -0
- package/dist/esm/testing/jest.config.cjs +1 -1
- package/dist/esm/testing/setup-tests.js +2 -2
- package/dist/esm/webpack/webpack.dev.babel.js +11 -4
- package/dist/esm/webpack/webpack.prod.babel.js +2 -1
- package/dist/types/lib/server/wsServer.d.ts +3 -7
- package/dist/types/lib/testing/ExtendedJSDomEnv.d.cts +5 -0
- package/dist/types/lib/testing/extended/axe-core/getMessageAndPass.d.ts +8 -0
- package/dist/types/lib/testing/extended/axe-core/index.d.ts +1 -0
- package/dist/types/lib/testing/extended/axe-core/reporter.d.ts +2 -0
- package/dist/types/lib/testing/extended/axe-core/shouldIgnoreNodeViolation.d.ts +2 -0
- package/dist/types/lib/testing/extended/axe-core/toHaveNoViolations.d.ts +12 -0
- package/dist/types/lib/tests/basic.test.d.ts +0 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
Binary file
|
package/dist/cjs/server/csp.js
CHANGED
|
@@ -80,7 +80,7 @@ const csp = (app) => {
|
|
|
80
80
|
useDefaults: false,
|
|
81
81
|
directives: {
|
|
82
82
|
defaultSrc: import_helmet.default.contentSecurityPolicy.dangerouslyDisableDefaultSrc,
|
|
83
|
-
baseUri: ["'
|
|
83
|
+
baseUri: ["'self'"],
|
|
84
84
|
frameAncestors: sources,
|
|
85
85
|
objectSrc: ["'none'"],
|
|
86
86
|
scriptSrc: getScriptSrc(),
|
package/dist/cjs/server/index.js
CHANGED
|
@@ -21,6 +21,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
|
+
var import_node_https = __toESM(require("node:https"), 1);
|
|
25
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
26
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
24
27
|
var import_express = __toESM(require("express"), 1);
|
|
25
28
|
var import_logger = require("./logger.js");
|
|
26
29
|
var import_middlewares = require("./middlewares.js");
|
|
@@ -32,14 +35,21 @@ var import_wsServer = require("./wsServer.js");
|
|
|
32
35
|
(0, import_middlewares.setupDefaultMiddlewares)(app);
|
|
33
36
|
await (0, import_appRoutes.loadRoutes)(app);
|
|
34
37
|
(0, import_middlewares.setupAdditionalMiddlewars)(app);
|
|
35
|
-
|
|
38
|
+
const options = {
|
|
39
|
+
pfx: import_node_fs.default.readFileSync(import_node_path.default.join(__dirname, "./certs/uiplatform.p12")),
|
|
40
|
+
passPhrase: "uiplatform"
|
|
41
|
+
};
|
|
42
|
+
const server = import_node_https.default.createServer(options, app);
|
|
43
|
+
server.listen(import_utils.port, import_utils.host, () => {
|
|
44
|
+
(0, import_wsServer.createWSServer)({ server }).then((wsServer) => {
|
|
45
|
+
app.locals.wsServer = wsServer;
|
|
46
|
+
}).catch((err) => {
|
|
47
|
+
import_logger.logger.error(err);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
});
|
|
36
50
|
import_logger.logger.appStarted(import_utils.port.toString(), import_utils.host || "localhost");
|
|
37
51
|
}).on("error", (err) => {
|
|
38
52
|
import_logger.logger.error(err);
|
|
39
53
|
process.exit(1);
|
|
40
54
|
});
|
|
41
|
-
const { wsServer } = await (0, import_wsServer.createWSServer)({
|
|
42
|
-
port: import_utils.wsPort
|
|
43
|
-
});
|
|
44
|
-
app.locals.wsServer = wsServer;
|
|
45
55
|
})();
|
|
@@ -31,10 +31,8 @@ __export(wsServer_exports, {
|
|
|
31
31
|
createWSServer: () => createWSServer
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(wsServer_exports);
|
|
34
|
-
var import_node_http = __toESM(require("node:http"), 1);
|
|
35
34
|
var wsLib = __toESM(require("ws"), 1);
|
|
36
35
|
const PING_INTERVAL = 3e4;
|
|
37
|
-
const DEFAULT_PORT = 5001;
|
|
38
36
|
const onSocketError = (err) => {
|
|
39
37
|
console.error(err);
|
|
40
38
|
};
|
|
@@ -50,7 +48,7 @@ const getAuthToken = (protocols) => {
|
|
|
50
48
|
return authProtocol.split("--")[1]?.trim?.();
|
|
51
49
|
};
|
|
52
50
|
const createWSServer = ({
|
|
53
|
-
|
|
51
|
+
server,
|
|
54
52
|
pingInterval = PING_INTERVAL,
|
|
55
53
|
onOpen
|
|
56
54
|
}) => {
|
|
@@ -58,9 +56,8 @@ const createWSServer = ({
|
|
|
58
56
|
const heartbeat = () => {
|
|
59
57
|
isAlive = true;
|
|
60
58
|
};
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
httpServer.on("upgrade", (req, socket, head) => {
|
|
59
|
+
const wsServer = new wsLib.WebSocketServer({ server });
|
|
60
|
+
server.on("upgrade", (req, socket, head) => {
|
|
64
61
|
socket.on("error", onSocketError);
|
|
65
62
|
wsServer.handleUpgrade(req, socket, head, (ws) => {
|
|
66
63
|
const protocols = req.headers["sec-websocket-protocol"]?.split(",");
|
|
@@ -116,10 +113,5 @@ const createWSServer = ({
|
|
|
116
113
|
wsServer.on("close", function close() {
|
|
117
114
|
clearInterval(interval);
|
|
118
115
|
});
|
|
119
|
-
return
|
|
120
|
-
httpServer.listen(port, () => {
|
|
121
|
-
console.log(`Websocket server listening on port ${port}`);
|
|
122
|
-
return resolve({ httpServer, wsServer });
|
|
123
|
-
});
|
|
124
|
-
});
|
|
116
|
+
return Promise.resolve(wsServer);
|
|
125
117
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { TestEnvironment } = require('jest-environment-jsdom');
|
|
2
|
+
|
|
3
|
+
// ICE platform is meant to be run on node > 18
|
|
4
|
+
// "jest-environment-jsdom": "~29.6.3" is instead meant to support node >16
|
|
5
|
+
// features that are supported since node 17 & 18 are not supported in jsdom env
|
|
6
|
+
// the limitation is not relevant for us since we are already running on node 18 anyway,
|
|
7
|
+
// this "ExtendedJSDomEnv" is an extension of the
|
|
8
|
+
// jest.config.cjs
|
|
9
|
+
// {
|
|
10
|
+
// ...
|
|
11
|
+
// testEnvironment: 'jsdom'
|
|
12
|
+
// ...
|
|
13
|
+
// }
|
|
14
|
+
// that actually uses node 18 features that are not supported in "jest-environment-jsdom": "~29.6.3"
|
|
15
|
+
|
|
16
|
+
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
|
|
17
|
+
class FixJSDOMEnvironment extends TestEnvironment {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
|
|
21
|
+
// From here on we are using "node" (currently running version of it) to polyfill jsdom this.global
|
|
22
|
+
|
|
23
|
+
// FIXME https://github.com/jsdom/jsdom/issues/3363
|
|
24
|
+
if (structuredClone) this.global.structuredClone = structuredClone;
|
|
25
|
+
|
|
26
|
+
// FIXME https://github.com/jsdom/jsdom/issues/1724
|
|
27
|
+
if (fetch) this.global.fetch = fetch;
|
|
28
|
+
if (Headers) this.global.Headers = Headers;
|
|
29
|
+
if (Request) this.global.Request = Request;
|
|
30
|
+
if (Response) this.global.Response = Response;
|
|
31
|
+
|
|
32
|
+
// FIXME https://github.com/jsdom/jsdom/issues/1721
|
|
33
|
+
if (URL) this.global.URL = URL;
|
|
34
|
+
if (Blob) this.global.Blob = Blob;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
module.exports = FixJSDOMEnvironment;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getMessageAndPass_exports = {};
|
|
20
|
+
__export(getMessageAndPass_exports, {
|
|
21
|
+
getMessageAndPass: () => getMessageAndPass
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getMessageAndPass_exports);
|
|
24
|
+
var import_jest_matcher_utils = require("jest-matcher-utils");
|
|
25
|
+
var import_reporter = require("./reporter.js");
|
|
26
|
+
const getMessageAndPass = (violations) => {
|
|
27
|
+
const formatedViolations = (0, import_reporter.reporter)(violations);
|
|
28
|
+
const pass = formatedViolations.length === 0;
|
|
29
|
+
if (pass) return { message: () => "", pass };
|
|
30
|
+
return {
|
|
31
|
+
message: () => `${(0, import_jest_matcher_utils.matcherHint)(".toHaveNoViolations")}
|
|
32
|
+
|
|
33
|
+
${formatedViolations}`,
|
|
34
|
+
pass
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var axe_core_exports = {};
|
|
20
|
+
__export(axe_core_exports, {
|
|
21
|
+
toHaveNoViolations: () => import_toHaveNoViolations.toHaveNoViolations
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(axe_core_exports);
|
|
24
|
+
var import_toHaveNoViolations = require("./toHaveNoViolations.js");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var reporter_exports = {};
|
|
20
|
+
__export(reporter_exports, {
|
|
21
|
+
reporter: () => reporter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(reporter_exports);
|
|
24
|
+
var import_jest_matcher_utils = require("jest-matcher-utils");
|
|
25
|
+
const colorYellow = (arg) => `\x1B[93m ${arg || ""} \x1B[0m`;
|
|
26
|
+
const colorGrey = (arg) => `\x1B[90m ${arg || ""} \x1B[0m`;
|
|
27
|
+
const colorBlue = (arg) => `\x1B[34m ${arg || ""} \x1B[0m`;
|
|
28
|
+
const reporter = (violToFormat) => {
|
|
29
|
+
if (violToFormat.length === 0) return "";
|
|
30
|
+
const lineBreak = "\n\n";
|
|
31
|
+
const horizontalLine = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
32
|
+
return violToFormat.map((violation) => {
|
|
33
|
+
const errorBody = violation.nodes.map((node) => {
|
|
34
|
+
const selector = node.target.join(", ");
|
|
35
|
+
const expectedText = `Expected the HTML found at $('${selector}') to have no violations:${lineBreak}`;
|
|
36
|
+
let violationHelpUrl = "";
|
|
37
|
+
if (violation.helpUrl)
|
|
38
|
+
violationHelpUrl = `You can find more information on this issue here:
|
|
39
|
+
${colorBlue(
|
|
40
|
+
violation.helpUrl
|
|
41
|
+
)}`;
|
|
42
|
+
return `${expectedText + colorGrey(node.html) + lineBreak}Received:${lineBreak}${(0, import_jest_matcher_utils.printReceived)(
|
|
43
|
+
`${violation.help} (${violation.id})`
|
|
44
|
+
)}${lineBreak}${colorYellow(
|
|
45
|
+
node.failureSummary
|
|
46
|
+
)}${lineBreak}${violationHelpUrl}`;
|
|
47
|
+
}).join(lineBreak);
|
|
48
|
+
return errorBody;
|
|
49
|
+
}).join(lineBreak + horizontalLine + lineBreak);
|
|
50
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var shouldIgnoreNodeViolation_exports = {};
|
|
20
|
+
__export(shouldIgnoreNodeViolation_exports, {
|
|
21
|
+
shouldIgnoreNodeViolation: () => shouldIgnoreNodeViolation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(shouldIgnoreNodeViolation_exports);
|
|
24
|
+
const dataAttributeRegexp = /(data-[\S]*)=["']([\S]*)["']/gm;
|
|
25
|
+
const shouldIgnoreNodeViolation = (node, violation) => [...node.html.matchAll(dataAttributeRegexp)].map(([fullMatch, dataKey, dataValue]) => ({
|
|
26
|
+
fullMatch,
|
|
27
|
+
dataKey,
|
|
28
|
+
dataValue
|
|
29
|
+
})).some(
|
|
30
|
+
({ dataKey, dataValue }) => dataKey === `data-axe-ignore-${violation.id}` && dataValue === "true"
|
|
31
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var toHaveNoViolations_exports = {};
|
|
20
|
+
__export(toHaveNoViolations_exports, {
|
|
21
|
+
toHaveNoViolations: () => toHaveNoViolations
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(toHaveNoViolations_exports);
|
|
24
|
+
var import_getMessageAndPass = require("./getMessageAndPass.js");
|
|
25
|
+
var import_shouldIgnoreNodeViolation = require("./shouldIgnoreNodeViolation.js");
|
|
26
|
+
const toHaveNoViolations = {
|
|
27
|
+
toHaveNoViolations(results) {
|
|
28
|
+
const { violations } = results;
|
|
29
|
+
const finalViolations = [];
|
|
30
|
+
violations.forEach((violation) => {
|
|
31
|
+
const { nodes } = violation;
|
|
32
|
+
const newNodes = [];
|
|
33
|
+
nodes.forEach((node) => {
|
|
34
|
+
if (!(0, import_shouldIgnoreNodeViolation.shouldIgnoreNodeViolation)(node, violation)) newNodes.push(node);
|
|
35
|
+
});
|
|
36
|
+
if (newNodes.length > 0) {
|
|
37
|
+
finalViolations.push({ ...violation, nodes: newNodes });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return { actual: violations, ...(0, import_getMessageAndPass.getMessageAndPass)(finalViolations) };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -95,7 +95,7 @@ const jestConfig = {
|
|
|
95
95
|
url: `http://localhost:3111${basePath}`,
|
|
96
96
|
resources: 'usable',
|
|
97
97
|
},
|
|
98
|
-
testEnvironment: '
|
|
98
|
+
testEnvironment: path.resolve(__dirname, './ExtendedJSDomEnv.cjs'),
|
|
99
99
|
watchPlugins: [
|
|
100
100
|
'jest-watch-typeahead/filename',
|
|
101
101
|
'jest-watch-typeahead/testname',
|
|
@@ -23,8 +23,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
var import_runtime = require("regenerator-runtime/runtime");
|
|
25
25
|
var import_extend_expect = require("@testing-library/jest-dom/extend-expect");
|
|
26
|
-
var import_jest_axe = __toESM(require("jest-axe"), 1);
|
|
27
26
|
var import_resize_observer_polyfill = __toESM(require("resize-observer-polyfill"), 1);
|
|
27
|
+
var import_axe_core = require("./extended/axe-core");
|
|
28
28
|
var import_matchMedia = require("./mocks/matchMedia.js");
|
|
29
29
|
var import_pui_diagnostics = require("./mocks/pui-diagnostics.js");
|
|
30
30
|
const originalError = console.error;
|
|
@@ -46,7 +46,7 @@ console.error = (...args) => {
|
|
|
46
46
|
return false;
|
|
47
47
|
return originalError(...args);
|
|
48
48
|
};
|
|
49
|
-
if (expect) expect.extend(
|
|
49
|
+
if (expect) expect.extend(import_axe_core.toHaveNoViolations);
|
|
50
50
|
const addElementToBody = (element) => {
|
|
51
51
|
const documentEle = (window || {}).document;
|
|
52
52
|
if (!documentEle) return null;
|
|
@@ -44,7 +44,6 @@ var import_middlewares = require("../server/middlewares.js");
|
|
|
44
44
|
var import_appRoutes = require("../server/appRoutes.js");
|
|
45
45
|
var import_helpers = require("./helpers.js");
|
|
46
46
|
var import_webpack_base_babel = require("./webpack.base.babel.js");
|
|
47
|
-
var import_utils = require("../server/utils.js");
|
|
48
47
|
var import_wsServer = require("../server/wsServer.js");
|
|
49
48
|
const import_meta = {};
|
|
50
49
|
const __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
|
|
@@ -112,7 +111,8 @@ const devConfig = {
|
|
|
112
111
|
appLoaderScriptPath,
|
|
113
112
|
diagnosticsScriptPath,
|
|
114
113
|
encwLoaderScriptPath,
|
|
115
|
-
googleTagManager: (0, import_helpers.isGoogleTagManagerEnabled)()
|
|
114
|
+
googleTagManager: (0, import_helpers.isGoogleTagManagerEnabled)(),
|
|
115
|
+
csp: process.env.CSP === "true"
|
|
116
116
|
}
|
|
117
117
|
}),
|
|
118
118
|
// new CspPlugin(HtmlWebpackPlugin, {
|
|
@@ -150,6 +150,13 @@ const devConfig = {
|
|
|
150
150
|
hot: true,
|
|
151
151
|
open: [basePath],
|
|
152
152
|
port: process.env.PORT || "auto",
|
|
153
|
+
server: {
|
|
154
|
+
type: "https",
|
|
155
|
+
options: {
|
|
156
|
+
pfx: import_node_path.default.join(__dirname, "../server/certs/uiplatform.p12"),
|
|
157
|
+
passphrase: "uiplatform"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
153
160
|
setupMiddlewares: (middlewares, devServer) => {
|
|
154
161
|
(0, import_interceptor_middleware.addCSPNonceMiddleware)(middlewares);
|
|
155
162
|
if (devServer.app) {
|
|
@@ -168,8 +175,8 @@ const devConfig = {
|
|
|
168
175
|
next();
|
|
169
176
|
});
|
|
170
177
|
(0, import_wsServer.createWSServer)({
|
|
171
|
-
|
|
172
|
-
}).then((
|
|
178
|
+
server: devServer.server
|
|
179
|
+
}).then((wsServer) => {
|
|
173
180
|
if (devServer.app) devServer.app.locals.wsServer = wsServer;
|
|
174
181
|
}).catch((err) => {
|
|
175
182
|
console.error(err);
|
|
@@ -137,7 +137,8 @@ const htmlWebpackPlugin = new import_html_webpack_plugin.default({
|
|
|
137
137
|
appLoaderScriptPath,
|
|
138
138
|
diagnosticsScriptPath,
|
|
139
139
|
encwLoaderScriptPath,
|
|
140
|
-
googleTagManager: (0, import_helpers.isGoogleTagManagerEnabled)()
|
|
140
|
+
googleTagManager: (0, import_helpers.isGoogleTagManagerEnabled)(),
|
|
141
|
+
csp: process.env.CSP === "true"
|
|
141
142
|
}
|
|
142
143
|
});
|
|
143
144
|
const config = (0, import_webpack_base_babel.baseConfig)(getProdConfig());
|
|
Binary file
|
package/dist/esm/server/csp.js
CHANGED
|
@@ -46,7 +46,7 @@ const csp = (app) => {
|
|
|
46
46
|
useDefaults: false,
|
|
47
47
|
directives: {
|
|
48
48
|
defaultSrc: helmet.contentSecurityPolicy.dangerouslyDisableDefaultSrc,
|
|
49
|
-
baseUri: ["'
|
|
49
|
+
baseUri: ["'self'"],
|
|
50
50
|
frameAncestors: sources,
|
|
51
51
|
objectSrc: ["'none'"],
|
|
52
52
|
scriptSrc: getScriptSrc(),
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import https from "node:https";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
1
4
|
import express from "express";
|
|
2
5
|
import { logger } from "./logger.js";
|
|
3
6
|
import {
|
|
4
7
|
setupDefaultMiddlewares,
|
|
5
8
|
setupAdditionalMiddlewars
|
|
6
9
|
} from "./middlewares.js";
|
|
7
|
-
import { port,
|
|
10
|
+
import { port, host } from "./utils.js";
|
|
8
11
|
import { loadRoutes } from "./appRoutes.js";
|
|
9
12
|
import { createWSServer } from "./wsServer.js";
|
|
10
13
|
(async function startServer() {
|
|
@@ -12,14 +15,21 @@ import { createWSServer } from "./wsServer.js";
|
|
|
12
15
|
setupDefaultMiddlewares(app);
|
|
13
16
|
await loadRoutes(app);
|
|
14
17
|
setupAdditionalMiddlewars(app);
|
|
15
|
-
|
|
18
|
+
const options = {
|
|
19
|
+
pfx: fs.readFileSync(path.join(__dirname, "./certs/uiplatform.p12")),
|
|
20
|
+
passPhrase: "uiplatform"
|
|
21
|
+
};
|
|
22
|
+
const server = https.createServer(options, app);
|
|
23
|
+
server.listen(port, host, () => {
|
|
24
|
+
createWSServer({ server }).then((wsServer) => {
|
|
25
|
+
app.locals.wsServer = wsServer;
|
|
26
|
+
}).catch((err) => {
|
|
27
|
+
logger.error(err);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|
|
16
30
|
logger.appStarted(port.toString(), host || "localhost");
|
|
17
31
|
}).on("error", (err) => {
|
|
18
32
|
logger.error(err);
|
|
19
33
|
process.exit(1);
|
|
20
34
|
});
|
|
21
|
-
const { wsServer } = await createWSServer({
|
|
22
|
-
port: wsPort
|
|
23
|
-
});
|
|
24
|
-
app.locals.wsServer = wsServer;
|
|
25
35
|
})();
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import http from "node:http";
|
|
2
1
|
import * as wsLib from "ws";
|
|
3
2
|
const PING_INTERVAL = 3e4;
|
|
4
|
-
const DEFAULT_PORT = 5001;
|
|
5
3
|
const onSocketError = (err) => {
|
|
6
4
|
console.error(err);
|
|
7
5
|
};
|
|
@@ -17,7 +15,7 @@ const getAuthToken = (protocols) => {
|
|
|
17
15
|
return authProtocol.split("--")[1]?.trim?.();
|
|
18
16
|
};
|
|
19
17
|
const createWSServer = ({
|
|
20
|
-
|
|
18
|
+
server,
|
|
21
19
|
pingInterval = PING_INTERVAL,
|
|
22
20
|
onOpen
|
|
23
21
|
}) => {
|
|
@@ -25,9 +23,8 @@ const createWSServer = ({
|
|
|
25
23
|
const heartbeat = () => {
|
|
26
24
|
isAlive = true;
|
|
27
25
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
httpServer.on("upgrade", (req, socket, head) => {
|
|
26
|
+
const wsServer = new wsLib.WebSocketServer({ server });
|
|
27
|
+
server.on("upgrade", (req, socket, head) => {
|
|
31
28
|
socket.on("error", onSocketError);
|
|
32
29
|
wsServer.handleUpgrade(req, socket, head, (ws) => {
|
|
33
30
|
const protocols = req.headers["sec-websocket-protocol"]?.split(",");
|
|
@@ -83,12 +80,7 @@ const createWSServer = ({
|
|
|
83
80
|
wsServer.on("close", function close() {
|
|
84
81
|
clearInterval(interval);
|
|
85
82
|
});
|
|
86
|
-
return
|
|
87
|
-
httpServer.listen(port, () => {
|
|
88
|
-
console.log(`Websocket server listening on port ${port}`);
|
|
89
|
-
return resolve({ httpServer, wsServer });
|
|
90
|
-
});
|
|
91
|
-
});
|
|
83
|
+
return Promise.resolve(wsServer);
|
|
92
84
|
};
|
|
93
85
|
export {
|
|
94
86
|
createWSServer
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { TestEnvironment } = require('jest-environment-jsdom');
|
|
2
|
+
|
|
3
|
+
// ICE platform is meant to be run on node > 18
|
|
4
|
+
// "jest-environment-jsdom": "~29.6.3" is instead meant to support node >16
|
|
5
|
+
// features that are supported since node 17 & 18 are not supported in jsdom env
|
|
6
|
+
// the limitation is not relevant for us since we are already running on node 18 anyway,
|
|
7
|
+
// this "ExtendedJSDomEnv" is an extension of the
|
|
8
|
+
// jest.config.cjs
|
|
9
|
+
// {
|
|
10
|
+
// ...
|
|
11
|
+
// testEnvironment: 'jsdom'
|
|
12
|
+
// ...
|
|
13
|
+
// }
|
|
14
|
+
// that actually uses node 18 features that are not supported in "jest-environment-jsdom": "~29.6.3"
|
|
15
|
+
|
|
16
|
+
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
|
|
17
|
+
class FixJSDOMEnvironment extends TestEnvironment {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
|
|
21
|
+
// From here on we are using "node" (currently running version of it) to polyfill jsdom this.global
|
|
22
|
+
|
|
23
|
+
// FIXME https://github.com/jsdom/jsdom/issues/3363
|
|
24
|
+
if (structuredClone) this.global.structuredClone = structuredClone;
|
|
25
|
+
|
|
26
|
+
// FIXME https://github.com/jsdom/jsdom/issues/1724
|
|
27
|
+
if (fetch) this.global.fetch = fetch;
|
|
28
|
+
if (Headers) this.global.Headers = Headers;
|
|
29
|
+
if (Request) this.global.Request = Request;
|
|
30
|
+
if (Response) this.global.Response = Response;
|
|
31
|
+
|
|
32
|
+
// FIXME https://github.com/jsdom/jsdom/issues/1721
|
|
33
|
+
if (URL) this.global.URL = URL;
|
|
34
|
+
if (Blob) this.global.Blob = Blob;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
module.exports = FixJSDOMEnvironment;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { matcherHint } from "jest-matcher-utils";
|
|
2
|
+
import { reporter } from "./reporter.js";
|
|
3
|
+
const getMessageAndPass = (violations) => {
|
|
4
|
+
const formatedViolations = reporter(violations);
|
|
5
|
+
const pass = formatedViolations.length === 0;
|
|
6
|
+
if (pass) return { message: () => "", pass };
|
|
7
|
+
return {
|
|
8
|
+
message: () => `${matcherHint(".toHaveNoViolations")}
|
|
9
|
+
|
|
10
|
+
${formatedViolations}`,
|
|
11
|
+
pass
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
getMessageAndPass
|
|
16
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { printReceived } from "jest-matcher-utils";
|
|
2
|
+
const colorYellow = (arg) => `\x1B[93m ${arg || ""} \x1B[0m`;
|
|
3
|
+
const colorGrey = (arg) => `\x1B[90m ${arg || ""} \x1B[0m`;
|
|
4
|
+
const colorBlue = (arg) => `\x1B[34m ${arg || ""} \x1B[0m`;
|
|
5
|
+
const reporter = (violToFormat) => {
|
|
6
|
+
if (violToFormat.length === 0) return "";
|
|
7
|
+
const lineBreak = "\n\n";
|
|
8
|
+
const horizontalLine = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
9
|
+
return violToFormat.map((violation) => {
|
|
10
|
+
const errorBody = violation.nodes.map((node) => {
|
|
11
|
+
const selector = node.target.join(", ");
|
|
12
|
+
const expectedText = `Expected the HTML found at $('${selector}') to have no violations:${lineBreak}`;
|
|
13
|
+
let violationHelpUrl = "";
|
|
14
|
+
if (violation.helpUrl)
|
|
15
|
+
violationHelpUrl = `You can find more information on this issue here:
|
|
16
|
+
${colorBlue(
|
|
17
|
+
violation.helpUrl
|
|
18
|
+
)}`;
|
|
19
|
+
return `${expectedText + colorGrey(node.html) + lineBreak}Received:${lineBreak}${printReceived(
|
|
20
|
+
`${violation.help} (${violation.id})`
|
|
21
|
+
)}${lineBreak}${colorYellow(
|
|
22
|
+
node.failureSummary
|
|
23
|
+
)}${lineBreak}${violationHelpUrl}`;
|
|
24
|
+
}).join(lineBreak);
|
|
25
|
+
return errorBody;
|
|
26
|
+
}).join(lineBreak + horizontalLine + lineBreak);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
reporter
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const dataAttributeRegexp = /(data-[\S]*)=["']([\S]*)["']/gm;
|
|
2
|
+
const shouldIgnoreNodeViolation = (node, violation) => [...node.html.matchAll(dataAttributeRegexp)].map(([fullMatch, dataKey, dataValue]) => ({
|
|
3
|
+
fullMatch,
|
|
4
|
+
dataKey,
|
|
5
|
+
dataValue
|
|
6
|
+
})).some(
|
|
7
|
+
({ dataKey, dataValue }) => dataKey === `data-axe-ignore-${violation.id}` && dataValue === "true"
|
|
8
|
+
);
|
|
9
|
+
export {
|
|
10
|
+
shouldIgnoreNodeViolation
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getMessageAndPass } from "./getMessageAndPass.js";
|
|
2
|
+
import { shouldIgnoreNodeViolation } from "./shouldIgnoreNodeViolation.js";
|
|
3
|
+
const toHaveNoViolations = {
|
|
4
|
+
toHaveNoViolations(results) {
|
|
5
|
+
const { violations } = results;
|
|
6
|
+
const finalViolations = [];
|
|
7
|
+
violations.forEach((violation) => {
|
|
8
|
+
const { nodes } = violation;
|
|
9
|
+
const newNodes = [];
|
|
10
|
+
nodes.forEach((node) => {
|
|
11
|
+
if (!shouldIgnoreNodeViolation(node, violation)) newNodes.push(node);
|
|
12
|
+
});
|
|
13
|
+
if (newNodes.length > 0) {
|
|
14
|
+
finalViolations.push({ ...violation, nodes: newNodes });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return { actual: violations, ...getMessageAndPass(finalViolations) };
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
toHaveNoViolations
|
|
22
|
+
};
|
|
@@ -95,7 +95,7 @@ const jestConfig = {
|
|
|
95
95
|
url: `http://localhost:3111${basePath}`,
|
|
96
96
|
resources: 'usable',
|
|
97
97
|
},
|
|
98
|
-
testEnvironment: '
|
|
98
|
+
testEnvironment: path.resolve(__dirname, './ExtendedJSDomEnv.cjs'),
|
|
99
99
|
watchPlugins: [
|
|
100
100
|
'jest-watch-typeahead/filename',
|
|
101
101
|
'jest-watch-typeahead/testname',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
2
|
import "@testing-library/jest-dom/extend-expect";
|
|
3
|
-
import jestAxe from "jest-axe";
|
|
4
3
|
import ResizeObserver from "resize-observer-polyfill";
|
|
4
|
+
import { toHaveNoViolations } from "./extended/axe-core";
|
|
5
5
|
import { addMatchMedia } from "./mocks/matchMedia.js";
|
|
6
6
|
import { logger } from "./mocks/pui-diagnostics.js";
|
|
7
7
|
const originalError = console.error;
|
|
@@ -23,7 +23,7 @@ console.error = (...args) => {
|
|
|
23
23
|
return false;
|
|
24
24
|
return originalError(...args);
|
|
25
25
|
};
|
|
26
|
-
if (expect) expect.extend(
|
|
26
|
+
if (expect) expect.extend(toHaveNoViolations);
|
|
27
27
|
const addElementToBody = (element) => {
|
|
28
28
|
const documentEle = (window || {}).document;
|
|
29
29
|
if (!documentEle) return null;
|