@elliemae/pui-cli 8.42.0-alpha.1 → 8.42.0-alpha.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.
@@ -80,7 +80,7 @@ const csp = (app) => {
80
80
  useDefaults: false,
81
81
  directives: {
82
82
  defaultSrc: import_helmet.default.contentSecurityPolicy.dangerouslyDisableDefaultSrc,
83
- baseUri: ["'none'"],
83
+ baseUri: ["'self'"],
84
84
  frameAncestors: sources,
85
85
  objectSrc: ["'none'"],
86
86
  scriptSrc: getScriptSrc(),
@@ -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
- app.listen(import_utils.port, import_utils.host, () => {
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
- port = DEFAULT_PORT,
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 httpServer = import_node_http.default.createServer();
62
- const wsServer = new wsLib.WebSocketServer({ noServer: true });
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 new Promise((resolve) => {
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
  };
@@ -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
- port: import_utils.wsPort
172
- }).then(({ wsServer }) => {
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());
@@ -46,7 +46,7 @@ const csp = (app) => {
46
46
  useDefaults: false,
47
47
  directives: {
48
48
  defaultSrc: helmet.contentSecurityPolicy.dangerouslyDisableDefaultSrc,
49
- baseUri: ["'none'"],
49
+ baseUri: ["'self'"],
50
50
  frameAncestors: sources,
51
51
  objectSrc: ["'none'"],
52
52
  scriptSrc: getScriptSrc(),
@@ -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, wsPort, host } from "./utils.js";
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
- app.listen(port, host, () => {
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
- port = DEFAULT_PORT,
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 httpServer = http.createServer();
29
- const wsServer = new wsLib.WebSocketServer({ noServer: true });
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 new Promise((resolve) => {
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
@@ -15,7 +15,6 @@ import {
15
15
  isGoogleTagManagerEnabled
16
16
  } from "./helpers.js";
17
17
  import { baseConfig } from "./webpack.base.babel.js";
18
- import { wsPort } from "../server/utils.js";
19
18
  import { createWSServer } from "../server/wsServer.js";
20
19
  const __filename = fileURLToPath(import.meta.url);
21
20
  const {
@@ -82,7 +81,8 @@ const devConfig = {
82
81
  appLoaderScriptPath,
83
82
  diagnosticsScriptPath,
84
83
  encwLoaderScriptPath,
85
- googleTagManager: isGoogleTagManagerEnabled()
84
+ googleTagManager: isGoogleTagManagerEnabled(),
85
+ csp: process.env.CSP === "true"
86
86
  }
87
87
  }),
88
88
  // new CspPlugin(HtmlWebpackPlugin, {
@@ -120,6 +120,13 @@ const devConfig = {
120
120
  hot: true,
121
121
  open: [basePath],
122
122
  port: process.env.PORT || "auto",
123
+ server: {
124
+ type: "https",
125
+ options: {
126
+ pfx: path.join(__dirname, "../server/certs/uiplatform.p12"),
127
+ passphrase: "uiplatform"
128
+ }
129
+ },
123
130
  setupMiddlewares: (middlewares, devServer) => {
124
131
  addCSPNonceMiddleware(middlewares);
125
132
  if (devServer.app) {
@@ -138,8 +145,8 @@ const devConfig = {
138
145
  next();
139
146
  });
140
147
  createWSServer({
141
- port: wsPort
142
- }).then(({ wsServer }) => {
148
+ server: devServer.server
149
+ }).then((wsServer) => {
143
150
  if (devServer.app) devServer.app.locals.wsServer = wsServer;
144
151
  }).catch((err) => {
145
152
  console.error(err);
@@ -109,7 +109,8 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
109
109
  appLoaderScriptPath,
110
110
  diagnosticsScriptPath,
111
111
  encwLoaderScriptPath,
112
- googleTagManager: isGoogleTagManagerEnabled()
112
+ googleTagManager: isGoogleTagManagerEnabled(),
113
+ csp: process.env.CSP === "true"
113
114
  }
114
115
  });
115
116
  const config = baseConfig(getProdConfig());
@@ -1,12 +1,8 @@
1
- import http from 'node:http';
1
+ import https from 'node:https';
2
2
  import * as wsLib from 'ws';
3
- export interface Servers {
4
- httpServer: http.Server;
5
- wsServer: wsLib.WebSocketServer;
6
- }
7
3
  export interface WSServerOptions {
8
- port?: number;
4
+ server: https.Server;
9
5
  pingInterval?: number;
10
6
  onOpen?: (webSocket: wsLib.WebSocket) => void;
11
7
  }
12
- export declare const createWSServer: ({ port, pingInterval, onOpen, }: WSServerOptions) => Promise<Servers>;
8
+ export declare const createWSServer: ({ server, pingInterval, onOpen, }: WSServerOptions) => Promise<wsLib.WebSocketServer>;