Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-fred

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-fred - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

LICENSE

63

fred.js

@@ -46,2 +46,3 @@

node.fredUsername = n.username;
// note - credentials are not passed in with config

@@ -55,3 +56,2 @@ node.fredAPIKey = node.credentials?node.credentials.apikey : null;

// TODO: depending on whether it is a client or server, public or private etc. build the endpoint
if (node.isServer) {

@@ -76,8 +76,13 @@ if (node.private) {

function startconn() { // Connect to remote endpoint
var socket = new ws(node.path, {
headers: {
"X-Auth-User": node.fredUsername,
"X-Auth-Key": node.fredAPIKey
}
});
var opts = {};
if (node.fredUsername && node.fredAPIKey) {
opts = {
headers: {
"X-Auth-User": node.fredUsername,
"X-Auth-Key": node.fredAPIKey
}
};
}
var socket = new ws(node.path, opts);
node.server = socket; // keep for closing

@@ -110,2 +115,3 @@ handleConnection(socket);

}
node.emit('reconnecting');
node.tout = setTimeout(function(){ startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ?

@@ -127,2 +133,3 @@ }

}
node.emit('reconnecting');
node.tout = setTimeout(function(){ startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ?

@@ -133,2 +140,8 @@ }

// we need the fred username in order to proxy the web socket request, can't do anything without it
if (!node.fredUsername && !node.isServer) {
node.error(RED._("fred.errors.missing-username"));
return; // this will be caught in FredEndpointNode.prototype.broadcast and message will be shown on the node
}
if (node.isServer) {

@@ -246,3 +259,11 @@ var path = RED.settings.httpNodeRoot || "/";

else {
this.server.send(data);
if (this.server) {
this.server.send(data);
} else {
if (!this.fredUsername) {
this.emit('erro', RED._("fred.errors.missing-username"));
} else {
this.emit('erro', RED._("fred.errors.connect-error"));
}
}
}

@@ -287,4 +308,15 @@ }

this.serverConfig.on('closed', function() {
node.status({fill:"red",shape:"ring",text:"disconnected"});
if (node.serverConfig && node.serverConfig.unauthorized) {
node.status({fill: "red",shape:"dot",text:"unauthorized"});
} else if (node.serverConfig &&
!node.serverConfig.fredUsername &&
!node.serverConfig.isServer) {
node.status({fill: "red",shape:"dot",text: RED._("fred.errors.missing-username")});
} else {
node.status({fill:"red",shape:"ring",text:"disconnected"});
}
});
this.serverConfig.on('reconnecting', function() {
node.status({fill:"grey",shape:"ring",text:"reconnecting"});
});
} else {

@@ -325,4 +357,15 @@ this.error(RED._("fred.errors.missing-conf"));

this.serverConfig.on('closed', function() {
node.status({fill:"red",shape:"ring",text:"disconnected"});
if (node.serverConfig && node.serverConfig.unauthorized) {
node.status({fill: "red",shape:"dot",text:"unauthorized"});
} else if (node.serverConfig &&
!node.serverConfig.fredUsername &&
!node.serverConfig.isServer) {
node.status({fill: "red",shape:"dot",text: RED._("fred.errors.missing-username")});
} else {
node.status({fill:"red",shape:"ring",text:"disconnected"});
}
});
this.serverConfig.on('reconnecting', function() {
node.status({fill:"grey",shape:"ring",text:"reconnecting"});
});
}

@@ -329,0 +372,0 @@ this.on("input", function(msg) {

3

locales/en-US/fred.json

@@ -21,5 +21,6 @@ {

"send-error": "An error occurred while sending: ",
"missing-conf": "Missing server configuration"
"missing-conf": "Missing server configuration",
"missing-username": "Missing username in configuration"
}
}
}
{
"name": "node-red-contrib-fred",
"version": "0.0.1",
"description": "",
"version": "0.0.2",
"description": "Node set for linking FRED hosted Node-RED to devices",
"homepage": "https://fred.sensetecnic.com",
"license": "Apache-2.0",
"repository" : {
"type":"git",
"url":"https://github.com/SenseTecnic/node-red-contrib-fred.git"
},
"dependencies": {
"ws": "^1.1.0"
},
"repository": {
"type": "git",
"url": "https://github.com/SenseTecnic/node-red-contrib-fred/"
},
"license": "Apache-2.0",
"keywords": [

@@ -14,0 +15,0 @@ "node-red",

@@ -5,3 +5,3 @@ # node-red-contrib-fred

These nodes currently connect to FRED using web sockets. These nodes are based on the built in web sockets modules that come with Node-RED. As FRED evolves, the method of connecting to a FRED-hosted Node-RED may change (e.g. to use an MQTT intermediary). Using these nodes will make sure your device flows will continue to connect to FRED using the most optimal protocol.
These nodes currently connect to FRED using web sockets. These nodes are based on the built in web sockets modules that come with Node-RED. As FRED evolves, the method of connecting to a FRED-hosted Node-RED may change. Using these nodes will make sure your device flows will continue to connect to FRED using the most well supported protocol.

@@ -15,8 +15,7 @@ ## Install

Open your Node-RED instance and you should have a FRED input and output node available in the input and
output categories.
Open your Node-RED instance and you should have a FRED input and output node available in the input and output categories.
## Connecting to FRED
On FRED, create an named endpoint for your PC to connect to. For example, the following flow creates a private FRED input endpoint node called 'example' connected to a debug output node.
On FRED, create an named endpoint for your Pi or PC to connect to. For example, the following flow creates a private FRED input endpoint node called 'example' connected to a debug output node.

@@ -37,3 +36,3 @@ ```

This information only applies to installing these nodes on the FRED host, and is here (mostly) for Sense Tecnic employee information.
This information only applies to installing these nodes on the FRED host, and is here (mostly) for FRED licensees.

@@ -40,0 +39,0 @@ The package.json file contains a config property 'hostType' that can be 'client' (default) or 'server'.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc