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

@semilimes/node-red-semilimes

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semilimes/node-red-semilimes - npm Package Compare versions

Comparing version 0.9.7 to 0.9.8

examples/Control Lamp stateful persistent flow.json

117

examples/Local Tunnel flow.json

@@ -18,7 +18,7 @@ [

"port": "1880",
"path": "ui",
"path": "/",
"retryInterval": 10,
"retryTimeout": "1",
"x": 490,
"y": 280,
"x": 400,
"y": 180,
"wires": [

@@ -40,6 +40,2 @@ [

{
"p": "topic",
"vt": "str"
},
{
"p": "Command",

@@ -57,4 +53,4 @@ "v": "CREATE",

"payloadType": "date",
"x": 160,
"y": 260,
"x": 100,
"y": 180,
"wires": [

@@ -76,6 +72,2 @@ [

{
"p": "topic",
"vt": "str"
},
{
"p": "Command",

@@ -93,7 +85,7 @@ "v": "OPEN",

"payloadType": "date",
"x": 150,
"y": 300,
"x": 110,
"y": 400,
"wires": [
[
"0524510749435a86"
"8eb3b73956d04d6c"
]

@@ -112,6 +104,2 @@ ]

{
"p": "topic",
"vt": "str"
},
{
"p": "Command",

@@ -129,7 +117,7 @@ "v": "DELETE",

"payloadType": "date",
"x": 160,
"y": 380,
"x": 120,
"y": 480,
"wires": [
[
"0524510749435a86"
"8eb3b73956d04d6c"
]

@@ -148,6 +136,2 @@ ]

{
"p": "topic",
"vt": "str"
},
{
"p": "Command",

@@ -165,7 +149,7 @@ "v": "CLOSE",

"payloadType": "date",
"x": 150,
"y": 340,
"x": 110,
"y": 440,
"wires": [
[
"0524510749435a86"
"8eb3b73956d04d6c"
]

@@ -178,3 +162,3 @@ ]

"z": "9c78f3e70aecce9f",
"name": "debug 41",
"name": "Check Tunnel Id",
"active": true,

@@ -188,4 +172,4 @@ "tosidebar": true,

"statusType": "auto",
"x": 560,
"y": 340,
"x": 820,
"y": 180,
"wires": []

@@ -199,4 +183,4 @@ },

"info": "",
"x": 280,
"y": 120,
"x": 240,
"y": 60,
"wires": []

@@ -208,8 +192,65 @@ },

"z": "9c78f3e70aecce9f",
"name": "Configure the tunnel properties then Create and Open the tunnel. When done, Close. Delete if you are not going to use it anymore.",
"name": "1. Configure the tunnel properties and Create the tunnel",
"info": "",
"x": 510,
"y": 160,
"x": 340,
"y": 140,
"wires": []
},
{
"id": "8eb3b73956d04d6c",
"type": "change",
"z": "9c78f3e70aecce9f",
"name": "",
"rules": [
{
"t": "set",
"p": "TunnelId",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 280,
"wires": [
[
"0524510749435a86"
]
]
},
{
"id": "9803fb758cb28abb",
"type": "comment",
"z": "9c78f3e70aecce9f",
"name": "2. Copy the TunnelId generated in the response",
"info": "",
"x": 840,
"y": 140,
"wires": []
},
{
"id": "cdbb1ecff8288482",
"type": "comment",
"z": "9c78f3e70aecce9f",
"name": "3. Paste the TunnelId here for persistency",
"info": "",
"x": 420,
"y": 240,
"wires": []
},
{
"id": "2cb9309145681335",
"type": "comment",
"z": "9c78f3e70aecce9f",
"name": "4. Control the Tunnel with the configured Id",
"info": "",
"x": 200,
"y": 360,
"wires": []
}
]
{
"name": "@semilimes/node-red-semilimes",
"version": "0.9.7",
"version": "0.9.8",
"description": "The new semilimes connector which integrates with the public API",

@@ -5,0 +5,0 @@ "scripts": {

@@ -59,3 +59,3 @@ # Node-RED semilimes connector

5. Add an `Intentr` node and select `Channel - Send Message` and configure the channel
5. Add an `Intent` node and select `Channel - Send Message` and configure the channel

@@ -62,0 +62,0 @@ 6. Add a `sender` node and run.

@@ -9,2 +9,6 @@ "use strict";

var smeConnector = config.connector && RED.nodes.getNode(config.connector);
if (!smeConnector)
return;
this.submitText = config.submitText;

@@ -14,4 +18,4 @@ this.submitTextType = config.submitTextType;

this.retainStatus = config.retainStatus;
this.receiverId = config.receiverId;
this.receiverIdType = config.receiverIdType;
this.recipientId = config.recipientId;
this.recipientIdType = config.recipientIdType;
this.receiverType = config.receiverType;

@@ -23,2 +27,82 @@ this.refName = config.refName;

//Get my P2P Chats (Contacts)
RED.httpAdmin.get('/sme/recipients', function(req,res,next)
{
var connector = smeConnector;
node.log("Node connector: " + smeConnector);
var endpoint = "/account/contacts";
var httpMethod = "GET";
var data = {
parameters: {}
};
connector.callApi(endpoint, httpMethod, data)
.then(
value => {
res.json(value);
},
error => {
res.sendStatus(500).send(error);
}
)
.catch(error => {
res.sendStatus(500).send(error);
})
});
//Get my groupChats
RED.httpAdmin.get('/sme/groupChats', function(req,res,next)
{
var connector = smeConnector;
node.log("Node connector: " + smeConnector);
var endpoint = "/communication/groupChat";
var httpMethod = "GET";
var data = {
parameters: {}
};
connector.callApi(endpoint, httpMethod, data)
.then(
value => {
res.json(value);
},
error => {
res.sendStatus(500).send(error);
}
)
.catch(error => {
res.sendStatus(500).send(error);
})
});
//Get my channels
RED.httpAdmin.get('/sme/channels', function(req,res,next)
{
var connector = smeConnector;
node.log("Node connector: " + smeConnector);
var endpoint = "/communication/channel/my";
var httpMethod = "GET";
var data = {
parameters: {
owner: true,
editor: true,
subscriber: true
}
};
connector.callApi(endpoint, httpMethod, data)
.then(
value => {
res.json(value);
},
error => {
res.sendStatus(500).send(error);
}
)
.catch(error => {
res.sendStatus(500).send(error);
})
});
node.on('input', function (msg, send, done) {

@@ -33,3 +117,5 @@ send = send || function () { node.send.apply(node, arguments) }

var submitTextValue = smeHelper.getNodeConfigValue(node, msg, node.submitTextType, node.submitText);
var receiverIdValue = smeHelper.getNodeConfigValue(node, msg, node.receiverIdType, node.receiverId);
var recipientIdValue = smeHelper.getNodeConfigValue(node, msg, node.recipientIdType, node.recipientId);
var groupChatIdValue = smeHelper.getNodeConfigValue(node, msg, node.groupChatIdType, node.groupChatId);
var channelIdValue = smeHelper.getNodeConfigValue(node, msg, node.channelIdType, node.channelId);
var refNameValue = smeHelper.getNodeConfigValue(node, msg, node.refNameType, node.refName);

@@ -42,5 +128,25 @@

smeFormMsg.dataComponent.receiver = {};
if (node.receiverType != "none") {
smeFormMsg.dataComponent.receiver.id = receiverIdValue;
smeFormMsg.dataComponent.receiver.featureType = node.receiverType;
switch (node.receiverType) {
case 'none':
break;
case 'contact':
if (recipientIdValue) {
smeFormMsg.dataComponent.receiver.id = recipientIdValue;
smeFormMsg.dataComponent.receiver.featureType = node.receiverType;
}
break;
case 'groupchat':
if (groupChatIdValue) {
smeFormMsg.dataComponent.receiver.id = groupChatIdValue;
smeFormMsg.dataComponent.receiver.featureType = node.receiverType;
}
break;
case 'channel':
if (channelIdValue) {
smeFormMsg.dataComponent.receiver.id = channelIdValue;
smeFormMsg.dataComponent.receiver.featureType = node.receiverType;
}
break;
default:
break;
}

@@ -47,0 +153,0 @@ smeFormMsg.dataComponent.refName = refNameValue;

@@ -12,2 +12,4 @@ "use strict";

this.referenceType = config.referenceType;
this.messageId = config.messageId;
this.messageIdType = config.messageIdType;
this.saveLocation = config.saveLocation;

@@ -25,2 +27,3 @@ this.saveLocationType = config.saveLocationType;

var referenceValue = smeHelper.getNodeConfigValue(node, msg, node.referenceType, node.reference);
var messageIdValue = smeHelper.getNodeConfigValue(node, msg, node.messageIdType, node.messageId);

@@ -42,2 +45,9 @@ //filter submissions

if (isMatchedSubmissionMessage && messageIdValue) {
//filter submissions by message id
isMatchedSubmissionMessage =
smeReceivedMsg.eventBody.dataComponent.replyTo &&
smeReceivedMsg.eventBody.dataComponent.replyTo.messageId == messageIdValue;
}
if (isMatchedSubmissionMessage) {

@@ -47,6 +57,4 @@ if (node.saveLocation) {

var submission = {
submission: {
replyTo: smeReceivedMsg.eventBody.dataComponent.replyTo,
formComponents: smeReceivedMsg.eventBody.dataComponent.formComponents
}
replyTo: smeReceivedMsg.eventBody.dataComponent.replyTo,
formComponents: smeReceivedMsg.eventBody.dataComponent.formComponents
}

@@ -53,0 +61,0 @@ switch (node.saveLocationType) {

@@ -431,3 +431,3 @@ "use strict";

headers: {
'Content-Type': 'application/json',
'Content-Type': 'application/json; charset=UTF-8',
'Content-Length': (body && body.length) || 0,

@@ -489,4 +489,5 @@ },

if (body)
if (body) {
req.write(body);
}

@@ -493,0 +494,0 @@ req.end();

@@ -49,3 +49,5 @@ "use strict";

value => {
value.requestId = smeMsg.requestId || '';
if (typeof value === 'object') {
value.requestId = smeMsg.requestId || '';
}
smeHelper.addResponseMsg(msg, value);

@@ -56,3 +58,3 @@ send(msg, false);

reason => {
reason.requestId = smeMsg.requestId || '';
//reason.requestId = smeMsg.requestId || '';
smeHelper.addResponseMsg(msg, reason);

@@ -59,0 +61,0 @@ msg.error = reason;

@@ -56,6 +56,2 @@ "use strict";

//stream.on('data', (data) => {
// console.log('TCP :: DATA: ' + data);
//});
stream.pause();

@@ -95,2 +91,3 @@

var tunnelId = args.TunnelId;
var sshPort = args.SshPort;

@@ -117,2 +114,3 @@ var sshServer = args.SshServer;

node.send({
TunnelId: tunnelId,
TunnelStatus: 'started',

@@ -158,2 +156,3 @@ TunnelName: node.name,

node.send({
TunnelId : tunnelId,
TunnelStatus: 'connecting',

@@ -177,7 +176,7 @@ TunnelName: node.name,

node.serving = false;
stopTunnel(node);
stopTunnel(node, {TunnelId: tunnelId});
});
}
function stopTunnel(node) {
function stopTunnel(node, args) {
var sshConn = node.sshConn;

@@ -193,2 +192,3 @@ node.sshConn = null;

node.send({
TunnelId: args.TunnelId,
TunnelStatus: 'stopped',

@@ -252,2 +252,3 @@ TunnelName: node.name,

node.send({
TunnelId: node.tunnelId,
TunnelStatus: 'created',

@@ -273,6 +274,9 @@ TunnelName: node.name,

case 'OPEN':
if(node.tunnelId && !node.serving) {
//Tunnel has been created, open it
if((msg.TunnelId || node.tunnelId) && !node.serving) {
//Tunnel has been created or specified, open it
node.log(`Opening tunnel: ${node.tunnelId}`);
//if specified, use this, otherwise, look into the saved id
var tunnelIdToOpen = msg.TunnelId ?? node.TunnelId;
var promise = smeConnector.sendMessage({

@@ -282,3 +286,3 @@ endpoint: "/service/tunnel/open",

body: {
tunnelId: node.tunnelId
tunnelId: tunnelIdToOpen
}

@@ -290,5 +294,6 @@ });

//Initiate SSH connection
node.log(`Opened tunnel: ${node.tunnelId} with server port: ${value.data.port}`);
node.log(`Opened tunnel: ${tunnelIdToOpen} with server port: ${value.data.port}`);
node.serving = true;
startTunnel(node, {
TunnelId: tunnelIdToOpen,
SshPort: 22,

@@ -301,4 +306,4 @@ SshServer: value.data.host,

} else {
node.log(`Could not open tunnel: ${node.tunnelId}`);
done && done(`Error: tunnel ${node.tunnelId} not opened`);
node.log(`Could not open tunnel: ${tunnelIdToOpen}`);
done && done(`Error: tunnel ${tunnelIdToOpen} not opened`);
}

@@ -311,6 +316,6 @@ },

} else {
if (!node.tunnelId) {
done && done(`No tunnel found. Please create it first!`);
if (!(msg.TunnelId || node.tunnelId)) {
done && done(`No tunnel found. Please create it or specify one TunnelId in Open/Close/Delete commands!`);
} else if (node.serving) {
done && done(`SSH connection active. Close Tunnel first!`);
done && done(`SSH connection active. Close Tunnel ${msg.TunnelId ?? node.tunnelId} first!`);
}

@@ -320,12 +325,14 @@ }

case 'CLOSE':
if (node.tunnelId && node.serving) {
if ((msg.TunnelId || node.tunnelId) && node.serving) {
node.serving = false;
stopTunnel(node);
node.log(`Stopped tunnel: ${node.tunnelId} - ${node.name}`);
stopTunnel(node, {TunnelId: msg.TunnelId ?? node.tunnelId });
node.log(`Stopped tunnel: ${msg.TunnelId ?? node.tunnelId} - ${node.name}`);
}
break;
case 'DELETE':
if (node.tunnelId && !node.serving) {
node.log(`Deleting tunnel: ${node.tunnelId}`);
if ((msg.TunnelId || node.tunnelId) && !node.serving) {
node.log(`Deleting tunnel: ${msg.TunnelId ?? node.tunnelId}`);
var tunnelToDelete = msg.TunnelId ?? node.tunnelId;
var promise = smeConnector.sendMessage({

@@ -335,3 +342,3 @@ endpoint: "/service/tunnel/delete",

body: {
tunnelId: node.tunnelId
tunnelId: tunnelToDelete
}

@@ -342,12 +349,12 @@ });

if(value.success === true) {
node.log(`Deleted tunnel: ${node.tunnelId}`);
node.log(`Deleted tunnel: ${tunnelToDelete}`);
node.send({
TunnelStatus: 'deleted',
TunnelId: node.tunnelId,
TunnelId: tunnelToDelete,
TunnelName: node.name
}, false);
delete node.tunnelId;
if (msg.TunnelId == node.tunnelId) delete node.tunnelId;
} else {
node.log(`Could not delete tunnel: ${node.tunnelId}`);
done && done(`Error: tunnel ${node.tunnelId} not deleted`);
node.log(`Could not delete tunnel: ${tunnelToDelete}`);
done && done(`Error: tunnel ${tunnelToDelete} not deleted`);
}

@@ -354,0 +361,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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