Merge branch 'dev' into i18n-port-label

This commit is contained in:
Nick O'Leary 2019-03-03 11:52:12 +00:00 committed by GitHub
commit 6d8d826764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 94 additions and 15 deletions

15
API.md Normal file
View File

@ -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

View File

@ -438,6 +438,7 @@ module.exports = function(grunt) {
jsdoc : { jsdoc : {
modules: { modules: {
src: [ src: [
'API.md',
'packages/node_modules/node-red/lib/red.js', 'packages/node_modules/node-red/lib/red.js',
'packages/node_modules/@node-red/runtime/lib/index.js', 'packages/node_modules/@node-red/runtime/lib/index.js',
'packages/node_modules/@node-red/runtime/lib/api/*.js', 'packages/node_modules/@node-red/runtime/lib/api/*.js',
@ -451,7 +452,7 @@ module.exports = function(grunt) {
configure: './jsdoc.json' configure: './jsdoc.json'
} }
}, },
editor: { _editor: {
src: [ src: [
'packages/node_modules/@node-red/editor-client/src/js' 'packages/node_modules/@node-red/editor-client/src/js'
], ],
@ -612,5 +613,5 @@ module.exports = function(grunt) {
grunt.registerTask('docs', grunt.registerTask('docs',
'Generates API documentation', 'Generates API documentation',
['jsdoc','jsdoc2md']); ['jsdoc']);
}; };

View File

@ -159,6 +159,11 @@
that.uiSelect.css("margin"+d,m); that.uiSelect.css("margin"+d,m);
that.input.css("margin"+d,0); 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"); this.uiSelect.addClass("red-ui-typedInput-container");

View File

@ -49,11 +49,19 @@
<label for="node-input-useAuth" style="width: 70%;"><span data-i18n="httpin.basicauth"></span></label> <label for="node-input-useAuth" style="width: 70%;"><span data-i18n="httpin.basicauth"></span></label>
<div style="margin-left: 20px" class="node-input-useAuth-row hide"> <div style="margin-left: 20px" class="node-input-useAuth-row hide">
<div class="form-row"> <div class="form-row">
<label for="node-input-authType"><i class="fa fa-user-secret "></i> <span data-i18n="httpin.label.authType"></span></label>
<select type="text" id="node-input-authType" style="width:70%;">
<option value="basic" data-i18n="httpin.basic"></option>
<option value="digest" data-i18n="httpin.digest"></option>
<option value="bearer" data-i18n="httpin.bearer"></option>
</select>
</div>
<div class="form-row node-input-basic-row">
<label for="node-input-user"><i class="fa fa-user"></i> <span data-i18n="common.label.username"></span></label> <label for="node-input-user"><i class="fa fa-user"></i> <span data-i18n="common.label.username"></span></label>
<input type="text" id="node-input-user"> <input type="text" id="node-input-user">
</div> </div>
<div class="form-row"> <div class="form-row">
<label for="node-input-password"><i class="fa fa-lock"></i> <span data-i18n="common.label.password"></span></label> <label for="node-input-password"> <i class="fa fa-lock"></i> <span data-i18n="common.label.password" id="node-span-password"></span><span data-i18n="httpin.label.bearerToken" id="node-span-token" style="display:none"></span></label>
<input type="password" id="node-input-password"> <input type="password" id="node-input-password">
</div> </div>
</div> </div>
@ -93,7 +101,8 @@
paytoqs: {value: false}, paytoqs: {value: false},
url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} }, url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} },
tls: {type:"tls-config",required: false}, tls: {type:"tls-config",required: false},
proxy: {type:"http proxy",required: false} proxy: {type:"http proxy",required: false},
authType: {value: "basic"}
}, },
credentials: { credentials: {
user: {type:"text"}, user: {type:"text"},
@ -119,12 +128,29 @@
$("#node-input-useAuth").change(function() { $("#node-input-useAuth").change(function() {
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
$(".node-input-useAuth-row").show(); $(".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 { } else {
$(".node-input-useAuth-row").hide(); $(".node-input-useAuth-row").hide();
$('#node-input-authType').val('');
$('#node-input-user').val(''); $('#node-input-user').val('');
$('#node-input-password').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() { $("#node-input-method").change(function() {
if ($(this).val() == "GET") { if ($(this).val() == "GET") {
$(".node-input-paytoqs-row").show(); $(".node-input-paytoqs-row").show();

View File

@ -33,6 +33,7 @@ module.exports = function(RED) {
var tlsNode = RED.nodes.getNode(n.tls); var tlsNode = RED.nodes.getNode(n.tls);
} }
this.ret = n.ret || "txt"; this.ret = n.ret || "txt";
this.authType = n.authType || "basic";
if (RED.settings.httpRequestTimeout) { this.reqTimeout = parseInt(RED.settings.httpRequestTimeout) || 120000; } if (RED.settings.httpRequestTimeout) { this.reqTimeout = parseInt(RED.settings.httpRequestTimeout) || 120000; }
else { this.reqTimeout = 120000; } else { this.reqTimeout = 120000; }
@ -175,11 +176,29 @@ module.exports = function(RED) {
} }
} }
} }
if (this.credentials && this.credentials.user) { if (this.credentials) {
opts.auth = { if (this.authType === "basic") {
user: this.credentials.user, if (this.credentials.user) {
pass: this.credentials.password||"" 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; var payload = null;

View File

@ -402,11 +402,16 @@
"utf8String": "UTF8 string", "utf8String": "UTF8 string",
"binaryBuffer": "binary buffer", "binaryBuffer": "binary buffer",
"jsonObject": "parsed JSON object" "jsonObject": "parsed JSON object"
"authType": "Type",
"bearerToken": "Token"
}, },
"setby": "- set by msg.method -", "setby": "- set by msg.method -",
"basicauth": "Use basic authentication", "basicauth": "Use authentication",
"use-tls": "Enable secure (SSL/TLS) connection", "use-tls": "Enable secure (SSL/TLS) connection",
"tls-config":"TLS Configuration", "tls-config":"TLS Configuration",
"basic": "basic authentication",
"digest": "digest authentication",
"bearer": "bearer authentication",
"use-proxy": "Use proxy", "use-proxy": "Use proxy",
"proxy-config": "Proxy Configuration", "proxy-config": "Proxy Configuration",
"use-proxyauth": "Use proxy authentication", "use-proxyauth": "Use proxy authentication",

View File

@ -20,6 +20,7 @@
*/ */
/** /**
* A WebSocket connection between the runtime and the editor.
* @typedef CommsConnection * @typedef CommsConnection
* @type {object} * @type {object}
* @property {string} session - a unique session identifier * @property {string} session - a unique session identifier

View File

@ -388,14 +388,14 @@ function stop(type,diff,muteLog) {
if (activeFlows.hasOwnProperty(id)) { if (activeFlows.hasOwnProperty(id)) {
var flowStateChanged = diff && (diff.added.indexOf(id) !== -1 || diff.removed.indexOf(id) !== -1); var flowStateChanged = diff && (diff.added.indexOf(id) !== -1 || diff.removed.indexOf(id) !== -1);
log.debug("red/nodes/flows.stop : stopping flow : "+id); 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) { if (type === "full" || flowStateChanged || diff.removed.indexOf(id)!==-1) {
delete activeFlows[id]; delete activeFlows[id];
} }
} }
} }
return Promise.resolve(promises).then(function() { return Promise.all(promises).then(function() {
for (id in activeNodesToFlow) { for (id in activeNodesToFlow) {
if (activeNodesToFlow.hasOwnProperty(id)) { if (activeNodesToFlow.hasOwnProperty(id)) {
if (!activeFlows[activeNodesToFlow[id]]) { if (!activeFlows[activeNodesToFlow[id]]) {

View File

@ -413,7 +413,7 @@ function setObjectProperty(msg,prop,value,createMissing) {
} }
} }
/** /*!
* Get value of environment variable. * Get value of environment variable.
* @param {Node} node - accessing node * @param {Node} node - accessing node
* @param {String} name - name of variable * @param {String} name - name of variable
@ -439,7 +439,7 @@ function getSetting(node, name) {
* @param {String} value - the string to parse * @param {String} value - the string to parse
* @param {Node} node - the node evaluating the property * @param {Node} node - the node evaluating the property
* @return {String} The parsed string * @return {String} The parsed string
* @memberof @node-red/util_util * @memberof @node-red/util_util
*/ */
function evaluateEnvProperty(value, node) { function evaluateEnvProperty(value, node) {
var result; var result;

View File

@ -39,6 +39,9 @@ function checkVersion(userSettings) {
* This module provides the full Node-RED application, with both the runtime * This module provides the full Node-RED application, with both the runtime
* and editor components built in. * and editor components built in.
* *
* The API this module exposes allows it to be embedded within another node.js
* application.
*
* @namespace node-red * @namespace node-red
*/ */
module.exports = { module.exports = {
@ -125,7 +128,11 @@ module.exports = {
/** /**
* This provides access to the internal nodes module of the * 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 * @memberof node-red
*/ */