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

node-red-viseo-helper

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-viseo-helper - npm Package Compare versions

Comparing version 0.2.0-alpha.7 to 0.2.0-alpha.8

0

CODE_OF_CONDUCT.md

@@ -0,0 +0,0 @@ # Contributor Covenant Code of Conduct

@@ -0,0 +0,0 @@ # Contributing to the Project

58

index.js

@@ -132,2 +132,3 @@ 'use strict';

const getContextValue = exports.getContextValue = (RED, node, data, str, type) => {
if (!str) return str;
try {

@@ -238,40 +239,48 @@ let value = RED.util.evaluateNodeProperty(str, type, node, data, null);

let activities = {};
let oldKeys = [];
let actKey = "";
exports.trackActivities = async function trackActivities(node) {
function unauth() {
function nextErr(err) {
node.status({fill:"red", shape:"ring", text: 'Missing VISEO Bot Maker key'});
node.error("Missing VISEO Bot Maker key - Read the documentation.")
node.error(err)
return false;
}
let conf = CONFIG || global.CONFIG;
let key = conf.key || '';
if (!actKey) {
let keyField = "VISEO_BOT_MAKER_KEY";
let conf = CONFIG || global.CONFIG;
let key = conf[keyField] || node.context().global.get(keyField);
if (!key) {
return nextErr("Missing VISEO Bot Maker key - Read the documentation.");
}
if ( key.length !== 40 || oldKeys.indexOf(key) !== -1) {
return nextErr("Invalid VISEO Bot Maker key - Read the documentation.");
}
actKey = key;
node.status({});
}
let time = Date.now();
if (!key) return unauth();
// First pass : set start time
if (!activities.info) {
activities = {
info : {
start : time,
key : key
}
};
if (!activities.info) {
// First pass : set start time
activities = { info : { start : time, key : actKey }};
}
else if (time - activities.info.start > 1000 ){ // 24h : 24 * 3600 * 1000 = 86400000
else if (time - activities.info.start > 86400000){
// 24h : 24 * 3600 * 1000 = 86400000
try {
node.warn(activities)
await sendActivities(activities);
activities = { info : { start : time, key : actKey }};
} catch(err) {
if (err.statusCode === 401) return unauth();
activities = { info : { start : time, key : actKey }};
if (err.statusCode === 401) return nextErr("Invalid VISEO Bot Maker key - Read the documentation.");
return true;
}
activities = {
info : {
start : time,
key : key
}
};
}
else {
// set the last time
// Set last time
activities.info.end = time;

@@ -294,3 +303,2 @@ }

activities[node.type].end = time;
activities.info.end = time;

@@ -313,3 +321,2 @@ return true;

// send data
let request = {

@@ -323,4 +330,3 @@ url: "https://nodedatafunction.azurewebsites.net/api/sendActivities?code=rriqcWx/cCsUQ0oxcVqTTaxsXWj5gf2AOCqhSayw8vaGaQKf6SgaQw==",

console.log(request)
return rp(request);
}

@@ -0,0 +0,0 @@ const extend = require('extend');

{
"name" : "node-red-viseo-helper",
"version" : "0.2.0-alpha.7",
"version" : "0.2.0-alpha.8",
"description" : "Utility libarary for Node-RED",

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

@@ -0,0 +0,0 @@ # Node-RED

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