From 97e789538e61847a54cf08def12eaa42972bd538 Mon Sep 17 00:00:00 2001 From: JeanCarl Date: Fri, 15 Feb 2019 14:40:19 -0800 Subject: [PATCH 1/5] Transfer placeholder and type to generated TypedInput field --- .../@node-red/editor-client/src/js/ui/common/typedInput.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js index 5f78a2c74..accfff6dd 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js @@ -159,6 +159,11 @@ that.uiSelect.css("margin"+d,m); that.input.css("margin"+d,0); }); + + ["type","placeholder"].forEach(function(d) { + var m = that.element.attr(d); + that.input.attr(d,m); + }); this.uiSelect.addClass("red-ui-typedInput-container"); From f4f664a4a20a1f98fe1be72586a7b5b0c05dd68d Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 27 Feb 2019 20:56:58 +0000 Subject: [PATCH 2/5] Ensure flows wait for all nodes to close before restarting Fixes #2067 --- .../node_modules/@node-red/runtime/lib/nodes/flows/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/flows/index.js b/packages/node_modules/@node-red/runtime/lib/nodes/flows/index.js index 4cce74e83..7963ddfc4 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/flows/index.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/flows/index.js @@ -388,14 +388,14 @@ function stop(type,diff,muteLog) { if (activeFlows.hasOwnProperty(id)) { var flowStateChanged = diff && (diff.added.indexOf(id) !== -1 || diff.removed.indexOf(id) !== -1); log.debug("red/nodes/flows.stop : stopping flow : "+id); - promises = promises.concat(activeFlows[id].stop(flowStateChanged?null:stopList,removedList)); + promises.push(activeFlows[id].stop(flowStateChanged?null:stopList,removedList)); if (type === "full" || flowStateChanged || diff.removed.indexOf(id)!==-1) { delete activeFlows[id]; } } } - return Promise.resolve(promises).then(function() { + return Promise.all(promises).then(function() { for (id in activeNodesToFlow) { if (activeNodesToFlow.hasOwnProperty(id)) { if (!activeFlows[activeNodesToFlow[id]]) { From e7b1ec6904b52c0a74fc6f1ffefca3fc154203cf Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Wed, 27 Feb 2019 23:15:31 +0100 Subject: [PATCH 3/5] Add Digest and Bearer Auth modes to http request node (#2061) * Authentication methods * Authentication methods * Authentication methods * Support undefined auth type * Support undefined auth type * Apply basic auth on existing nodes * Use password as bearer token * Use password as bearer token * Switch between password/token labels * Bearer token abbreviation * Separate token span --- .../nodes/core/io/21-httprequest.html | 30 +++++++++++++++++-- .../@node-red/nodes/core/io/21-httprequest.js | 29 ++++++++++++++---- .../nodes/locales/en-US/messages.json | 7 ++++- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html index a9c0f5544..5cf8f63e0 100644 --- a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html +++ b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html @@ -49,11 +49,19 @@
+ + +
+
- +
@@ -93,7 +101,8 @@ paytoqs: {value: false}, url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} }, tls: {type:"tls-config",required: false}, - proxy: {type:"http proxy",required: false} + proxy: {type:"http proxy",required: false}, + authType: {value: "basic"} }, credentials: { user: {type:"text"}, @@ -115,12 +124,29 @@ $("#node-input-useAuth").change(function() { if ($(this).is(":checked")) { $(".node-input-useAuth-row").show(); + // Nodes (< version 0.20.x) with credentials but without authentication type, need type 'basic' + if (!$('#node-input-authType').val()) { + $('#node-input-authType').val('basic'); + } } else { $(".node-input-useAuth-row").hide(); + $('#node-input-authType').val(''); $('#node-input-user').val(''); $('#node-input-password').val(''); } }); + $("#node-input-authType").change(function() { + if ($(this).val() == "basic" || $(this).val() == "digest") { + $(".node-input-basic-row").show(); + $('#node-span-password').show(); + $('#node-span-token').hide(); + } else if ($(this).val() == "bearer") { + $(".node-input-basic-row").hide(); + $('#node-span-password').hide(); + $('#node-span-token').show(); + $('#node-input-user').val(''); + } + }); $("#node-input-method").change(function() { if ($(this).val() == "GET") { $(".node-input-paytoqs-row").show(); diff --git a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js index cad6444a7..dae51ded7 100644 --- a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.js @@ -33,6 +33,7 @@ module.exports = function(RED) { var tlsNode = RED.nodes.getNode(n.tls); } this.ret = n.ret || "txt"; + this.authType = n.authType || "basic"; if (RED.settings.httpRequestTimeout) { this.reqTimeout = parseInt(RED.settings.httpRequestTimeout) || 120000; } else { this.reqTimeout = 120000; } @@ -175,11 +176,29 @@ module.exports = function(RED) { } } } - if (this.credentials && this.credentials.user) { - opts.auth = { - user: this.credentials.user, - pass: this.credentials.password||"" - }; + if (this.credentials) { + if (this.authType === "basic") { + if (this.credentials.user) { + opts.auth = { + user: this.credentials.user, + pass: this.credentials.password || "" + }; + } + } else if (this.authType === "digest") { + if (this.credentials.user) { + // The first request will be send without auth information. Based on the 401 response, the library can determine + // which auth type is required by the server. Then the request is resubmitted the with the appropriate auth header. + opts.auth = { + user: this.credentials.user, + pass: this.credentials.password || "", + sendImmediately: false + }; + } + } else if (this.authType === "bearer") { + opts.auth = { + bearer: this.credentials.password || "" + }; + } } var payload = null; diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index d8a6a8d20..97cfdc303 100755 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -380,12 +380,17 @@ "status": "Status code", "headers": "Headers", "other": "other", + "authType": "Type", + "bearerToken": "Token", "paytoqs" : "Append msg.payload as query string parameters" }, "setby": "- set by msg.method -", - "basicauth": "Use basic authentication", + "basicauth": "Use authentication", "use-tls": "Enable secure (SSL/TLS) connection", "tls-config":"TLS Configuration", + "basic": "basic authentication", + "digest": "digest authentication", + "bearer": "bearer authentication", "use-proxy": "Use proxy", "proxy-config": "Proxy Configuration", "use-proxyauth": "Use proxy authentication", From 236d437430620603bcbea58f205f1f61b7b39fd0 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 Feb 2019 22:21:22 +0000 Subject: [PATCH 4/5] Add api docs landing content --- API.md | 15 +++++++++++++++ Gruntfile.js | 5 +++-- .../@node-red/runtime/lib/api/comms.js | 1 + packages/node_modules/@node-red/util/lib/util.js | 4 ++-- packages/node_modules/node-red/lib/red.js | 9 ++++++++- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 API.md diff --git a/API.md b/API.md new file mode 100644 index 000000000..f349ea8fe --- /dev/null +++ b/API.md @@ -0,0 +1,15 @@ +Node-RED Modules +--- + +Node-RED provides a set of node modules that implement different parts of the +application. + +Module | Description +-------|------- +[node-red](node-red.html) | the main module that pulls together all of the internal modules and provides the executable version of Node-RED +[@node-red/editor-api](@node-red_editor-api.html) | an Express application that serves the Node-RED editor and provides the Admin HTTP API +[@node-red/runtime](@node-red_runtime.html) | the core runtime of Node-RED +[@node-red/util](@node-red_util.html) | common utilities for the Node-RED runtime and editor modules +@node-red/registry | the internal node registry +@node-red/nodes | the default set of core nodes +@node-red/editor-client | the client-side resources of the Node-RED editor application diff --git a/Gruntfile.js b/Gruntfile.js index 3e8740e7d..e11caabbc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -438,6 +438,7 @@ module.exports = function(grunt) { jsdoc : { modules: { src: [ + 'API.md', 'packages/node_modules/node-red/lib/red.js', 'packages/node_modules/@node-red/runtime/lib/index.js', 'packages/node_modules/@node-red/runtime/lib/api/*.js', @@ -451,7 +452,7 @@ module.exports = function(grunt) { configure: './jsdoc.json' } }, - editor: { + _editor: { src: [ 'packages/node_modules/@node-red/editor-client/src/js' ], @@ -612,5 +613,5 @@ module.exports = function(grunt) { grunt.registerTask('docs', 'Generates API documentation', - ['jsdoc','jsdoc2md']); + ['jsdoc']); }; diff --git a/packages/node_modules/@node-red/runtime/lib/api/comms.js b/packages/node_modules/@node-red/runtime/lib/api/comms.js index 079f75c14..6c0d5a97a 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/comms.js +++ b/packages/node_modules/@node-red/runtime/lib/api/comms.js @@ -20,6 +20,7 @@ */ /** + * A WebSocket connection between the runtime and the editor. * @typedef CommsConnection * @type {object} * @property {string} session - a unique session identifier diff --git a/packages/node_modules/@node-red/util/lib/util.js b/packages/node_modules/@node-red/util/lib/util.js index 3283a621b..b4512f1ea 100644 --- a/packages/node_modules/@node-red/util/lib/util.js +++ b/packages/node_modules/@node-red/util/lib/util.js @@ -413,7 +413,7 @@ function setObjectProperty(msg,prop,value,createMissing) { } } -/** +/*! * Get value of environment variable. * @param {Node} node - accessing node * @param {String} name - name of variable @@ -439,7 +439,7 @@ function getSetting(node, name) { * @param {String} value - the string to parse * @param {Node} node - the node evaluating the property * @return {String} The parsed string -* @memberof @node-red/util_util + * @memberof @node-red/util_util */ function evaluateEnvProperty(value, node) { var result; diff --git a/packages/node_modules/node-red/lib/red.js b/packages/node_modules/node-red/lib/red.js index b679ad138..2a04df578 100644 --- a/packages/node_modules/node-red/lib/red.js +++ b/packages/node_modules/node-red/lib/red.js @@ -39,6 +39,9 @@ function checkVersion(userSettings) { * This module provides the full Node-RED application, with both the runtime * and editor components built in. * + * The API this module exposes allows it to be embedded within another node.js + * application. + * * @namespace node-red */ module.exports = { @@ -125,7 +128,11 @@ module.exports = { /** * This provides access to the internal nodes module of the - * runtime. + * runtime. The details of this API remain undocumented as they should not + * be used directly. + * + * Most administrative actions should be performed use the runtime api + * under [node-red.runtime]{@link node-red.runtime}. * * @memberof node-red */ From 4844c2123f5386553f065cf1a6413d452980461c Mon Sep 17 00:00:00 2001 From: bartbutenaers Date: Fri, 1 Mar 2019 23:18:48 +0100 Subject: [PATCH 5/5] Fix hiding Bearer token --- .../node_modules/@node-red/nodes/core/io/21-httprequest.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html index 5cf8f63e0..af67599d0 100644 --- a/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html +++ b/packages/node_modules/@node-red/nodes/core/io/21-httprequest.html @@ -61,7 +61,7 @@
- +