@node-red/editor-api 2.0.6 → 2.1.1

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/lib/auth/index.js CHANGED
@@ -199,8 +199,12 @@ function genericStrategy(adminApp,strategy) {
199
199
  passport.use(new strategy.strategy(options, verify));
200
200
 
201
201
  adminApp.get('/auth/strategy',
202
- passport.authenticate(strategy.name, {session:false, failureRedirect: settings.httpAdminRoot }),
203
- completeGenerateStrategyAuth
202
+ passport.authenticate(strategy.name, {session:false,
203
+ failureMessage: true,
204
+ failureRedirect: settings.httpAdminRoot
205
+ }),
206
+ completeGenerateStrategyAuth,
207
+ handleStrategyError
204
208
  );
205
209
 
206
210
  var callbackMethodFunc = adminApp.get;
@@ -208,8 +212,13 @@ function genericStrategy(adminApp,strategy) {
208
212
  callbackMethodFunc = adminApp.post;
209
213
  }
210
214
  callbackMethodFunc.call(adminApp,'/auth/strategy/callback',
211
- passport.authenticate(strategy.name, {session:false, failureRedirect: settings.httpAdminRoot }),
212
- completeGenerateStrategyAuth
215
+ passport.authenticate(strategy.name, {
216
+ session:false,
217
+ failureMessage: true,
218
+ failureRedirect: settings.httpAdminRoot
219
+ }),
220
+ completeGenerateStrategyAuth,
221
+ handleStrategyError
213
222
  );
214
223
 
215
224
  }
@@ -219,6 +228,13 @@ function completeGenerateStrategyAuth(req,res) {
219
228
  // Successful authentication, redirect home.
220
229
  res.redirect(settings.httpAdminRoot + '?access_token='+tokens.accessToken);
221
230
  }
231
+ function handleStrategyError(err, req, res, next) {
232
+ if (res.headersSent) {
233
+ return next(err)
234
+ }
235
+ log.audit({event: "auth.login.fail.oauth",error:err.toString()});
236
+ res.redirect(settings.httpAdminRoot + '?session_message='+err.toString());
237
+ }
222
238
 
223
239
  module.exports = {
224
240
  init: init,
@@ -18,14 +18,6 @@ var apiUtils = require("../util");
18
18
  var express = require("express");
19
19
  var runtimeAPI;
20
20
 
21
- function getUsername(userObj) {
22
- var username = '__default';
23
- if ( userObj && userObj.name ) {
24
- username = userObj.name;
25
- }
26
- return username;
27
- }
28
-
29
21
  module.exports = {
30
22
  init: function(_runtimeAPI) {
31
23
  runtimeAPI = _runtimeAPI;
@@ -24,15 +24,19 @@ var defaultContext = {
24
24
  page: {
25
25
  title: "Node-RED",
26
26
  favicon: "favicon.ico",
27
- tabicon: "red/images/node-red-icon-black.svg"
27
+ tabicon: {
28
+ icon: "red/images/node-red-icon-black.svg",
29
+ colour: "#8f0000"
30
+ },
31
+ version: require(path.join(__dirname,"../../package.json")).version
28
32
  },
29
33
  header: {
30
34
  title: "Node-RED",
31
35
  image: "red/images/node-red.svg"
32
36
  },
33
37
  asset: {
34
- red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js",
35
- main: (process.env.NODE_ENV == "development")? "red/main.js":"red/main.min.js",
38
+ red: "red/red.min.js",
39
+ main: "red/main.min.js",
36
40
  vendorMonaco: ""
37
41
  }
38
42
  };
@@ -74,7 +78,7 @@ function serveFilesFromTheme(themeValue, themeApp, directory, baseDirectory) {
74
78
  let fullPath = array[i];
75
79
  if (baseDirectory) {
76
80
  fullPath = path.resolve(baseDirectory,array[i]);
77
- if (fullPath.indexOf(baseDirectory) !== 0) {
81
+ if (fullPath.indexOf(path.resolve(baseDirectory)) !== 0) {
78
82
  continue;
79
83
  }
80
84
  }
@@ -91,6 +95,10 @@ module.exports = {
91
95
  init: function(settings, _runtimeAPI) {
92
96
  runtimeAPI = _runtimeAPI;
93
97
  themeContext = clone(defaultContext);
98
+ if (process.env.NODE_ENV == "development") {
99
+ themeContext.asset.red = "red/red.js";
100
+ themeContext.asset.main = "red/main.js";
101
+ }
94
102
  themeSettings = null;
95
103
  theme = settings.editorTheme || {};
96
104
  themeContext.asset.vendorMonaco = ((theme.codeEditor || {}).lib === "monaco") ? "vendor/monaco/monaco-bootstrap.js" : "";
@@ -123,9 +131,13 @@ module.exports = {
123
131
  }
124
132
 
125
133
  if (theme.page.tabicon) {
126
- url = serveFile(themeApp,"/tabicon/",theme.page.tabicon)
134
+ let icon = theme.page.tabicon.icon || theme.page.tabicon
135
+ url = serveFile(themeApp,"/tabicon/", icon)
127
136
  if (url) {
128
- themeContext.page.tabicon = url;
137
+ themeContext.page.tabicon.icon = url;
138
+ }
139
+ if (theme.page.tabicon.colour) {
140
+ themeContext.page.tabicon.colour = theme.page.tabicon.colour
129
141
  }
130
142
  }
131
143
 
@@ -246,6 +258,9 @@ module.exports = {
246
258
  theme.page = theme.page || {_:{}}
247
259
  theme.page._.scripts = scriptFiles.concat(theme.page._.scripts || [])
248
260
  }
261
+ if(theme.codeEditor) {
262
+ theme.codeEditor.options = Object.assign({}, themePlugin.monacoOptions, theme.codeEditor.options);
263
+ }
249
264
  }
250
265
  activeThemeInitialised = true;
251
266
  }
package/lib/editor/ui.js CHANGED
@@ -91,7 +91,16 @@ module.exports = {
91
91
  },
92
92
 
93
93
  editor: async function(req,res) {
94
- res.send(Mustache.render(editorTemplate,await theme.context()));
94
+
95
+ let sessionMessages;
96
+ if (req.session && req.session.messages) {
97
+ sessionMessages = JSON.stringify(req.session.messages);
98
+ delete req.session.messages
99
+ }
100
+ res.send(Mustache.render(editorTemplate,{
101
+ sessionMessages,
102
+ ...await theme.context()
103
+ }));
95
104
  },
96
105
  editorResources: express.static(path.join(editorClientDir,'public'))
97
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/editor-api",
3
- "version": "2.0.6",
3
+ "version": "2.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./lib/index.js",
6
6
  "repository": {
@@ -16,8 +16,8 @@
16
16
  }
17
17
  ],
18
18
  "dependencies": {
19
- "@node-red/util": "2.0.6",
20
- "@node-red/editor-client": "2.0.6",
19
+ "@node-red/util": "2.1.1",
20
+ "@node-red/editor-client": "2.1.1",
21
21
  "bcryptjs": "2.4.3",
22
22
  "body-parser": "1.19.0",
23
23
  "clone": "2.1.2",
@@ -31,7 +31,7 @@
31
31
  "oauth2orize": "1.11.0",
32
32
  "passport-http-bearer": "1.0.1",
33
33
  "passport-oauth2-client-password": "0.1.2",
34
- "passport": "0.4.1",
34
+ "passport": "0.5.0",
35
35
  "ws": "7.5.1"
36
36
  },
37
37
  "optionalDependencies": {