node-red 4.0.0-beta.4 → 4.0.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ #### 4.0.0: Milestone Release
2
+
3
+ This marks the next major release of Node-RED. The following changes represent
4
+ those added since the last beta. Check the beta release details below for the complete
5
+ list.
6
+
7
+ Breaking Changes
8
+
9
+ - Node-RED now requires Node 18.x or later. At the time of release, we recommend
10
+ using Node 20.
11
+
12
+ Editor
13
+
14
+ - Add `httpStaticCors` (#4761) @knolleary
15
+ - Update dependencies (#4763) @knolleary
16
+ - Sync master to dev (#4756) @knolleary
17
+ - Add tooltip and message validation to `typedInput` (#4747) @GogoVega
18
+ - Replace bcrypt with @node-rs/bcrypt (#4744) @knolleary
19
+ - Export Nodes dialog refinement (#4746) @Steve-Mcl
20
+
1
21
  #### 4.0.0-beta.4: Beta Release
2
22
 
3
23
  Editor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0",
4
4
  "description": "Low-code programming for event-driven applications",
5
5
  "homepage": "https://nodered.org",
6
6
  "license": "Apache-2.0",
@@ -31,20 +31,21 @@
31
31
  "flow"
32
32
  ],
33
33
  "dependencies": {
34
- "@node-red/editor-api": "4.0.0-beta.4",
35
- "@node-red/runtime": "4.0.0-beta.4",
36
- "@node-red/util": "4.0.0-beta.4",
37
- "@node-red/nodes": "4.0.0-beta.4",
34
+ "@node-red/editor-api": "4.0.0",
35
+ "@node-red/runtime": "4.0.0",
36
+ "@node-red/util": "4.0.0",
37
+ "@node-red/nodes": "4.0.0",
38
38
  "basic-auth": "2.0.1",
39
39
  "bcryptjs": "2.4.3",
40
+ "cors": "2.8.5",
40
41
  "express": "4.19.2",
41
42
  "fs-extra": "11.2.0",
42
- "node-red-admin": "^3.1.3",
43
+ "node-red-admin": "^4.0.0",
43
44
  "nopt": "5.0.0",
44
45
  "semver": "7.5.4"
45
46
  },
46
47
  "optionalDependencies": {
47
- "bcrypt": "5.1.1"
48
+ "@node-rs/bcrypt": "1.10.4"
48
49
  },
49
50
  "engines": {
50
51
  "node": ">=18.5"
package/red.js CHANGED
@@ -38,12 +38,14 @@ var https = require('https');
38
38
  var util = require("util");
39
39
  var express = require("express");
40
40
  var crypto = require("crypto");
41
- try { bcrypt = require('bcrypt'); }
41
+ try { bcrypt = require('@node-rs/bcrypt'); }
42
42
  catch(e) { bcrypt = require('bcryptjs'); }
43
43
  var nopt = require("nopt");
44
44
  var path = require("path");
45
45
  const os = require("os")
46
46
  var fs = require("fs-extra");
47
+ const cors = require('cors');
48
+
47
49
  var RED = require("./lib/red.js");
48
50
 
49
51
  var server;
@@ -441,10 +443,16 @@ httpsPromise.then(function(startupHttps) {
441
443
  const thisRoot = sp.root || "/";
442
444
  const options = sp.options;
443
445
  const middleware = sp.middleware;
446
+ const corsOptions = sp.cors || settings.httpStaticCors;
444
447
  if(appUseMem[filePath + "::" + thisRoot]) {
445
448
  continue;// this path and root already registered!
446
449
  }
447
450
  appUseMem[filePath + "::" + thisRoot] = true;
451
+ if (corsOptions) {
452
+ const corsHandler = cors(corsOptions);
453
+ app.options(thisRoot, corsHandler)
454
+ app.use(thisRoot, corsHandler)
455
+ }
448
456
  if (settings.httpStaticAuth) {
449
457
  app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass));
450
458
  }
package/settings.js CHANGED
@@ -139,6 +139,7 @@ module.exports = {
139
139
  * - httpNodeMiddleware
140
140
  * - httpStatic
141
141
  * - httpStaticRoot
142
+ * - httpStaticCors
142
143
  ******************************************************************************/
143
144
 
144
145
  /** the tcp port that the Node-RED web server is listening on */
@@ -233,6 +234,9 @@ module.exports = {
233
234
  * OR multiple static sources can be created using an array of objects...
234
235
  * Each object can also contain an options object for further configuration.
235
236
  * See https://expressjs.com/en/api.html#express.static for available options.
237
+ * They can also contain an option `cors` object to set specific Cross-Origin
238
+ * Resource Sharing rules for the source. `httpStaticCors` can be used to
239
+ * set a default cors policy across all static routes.
236
240
  */
237
241
  //httpStatic: [
238
242
  // {path: '/home/nol/pics/', root: "/img/"},
@@ -250,6 +254,16 @@ module.exports = {
250
254
  */
251
255
  //httpStaticRoot: '/static/',
252
256
 
257
+ /** The following property can be used to configure cross-origin resource sharing
258
+ * in the http static routes.
259
+ * See https://github.com/troygoode/node-cors#configuration-options for
260
+ * details on its contents. The following is a basic permissive set of options:
261
+ */
262
+ //httpStaticCors: {
263
+ // origin: "*",
264
+ // methods: "GET,PUT,POST,DELETE"
265
+ //},
266
+
253
267
  /** The following property can be used to modify proxy options */
254
268
  // proxyOptions: {
255
269
  // mode: "legacy", // legacy mode is for non-strict previous proxy determination logic (node-red < v4 compatible)