Commit 5b630875 by Chavee Issariyapat

reverse content to revision 58b6cecc which is using on k8s

parent 267dea68
......@@ -9,15 +9,11 @@ RUN apk add --update --no-cache python \
py-pip \
yarn \
openssh-client \
git \
&& rm -rf /var/cache/apk/*
COPY . .
RUN npm install
RUN apk del git \
&& rm -rf /var/cache/apk/*
EXPOSE 40000
CMD npm start
var config = require('config');
// https://github.com/isaacs/node-lru-cache
var LRU = require("lru-cache"),
var LRU = require("lru-cache") ,
cache = LRU({
max: 500,
maxAge: 1000 * 60 * 5
});
module.exports = function (options = {}) {
return function (req, res, next) {
// for testing
function authCheck(client_id, username, topic, callback) {
callback(true);
}
module.exports = function(options={}) {
return function(req, res, next) {
if (req.header('vernemq-hook') == 'auth_on_publish' && req && req.body) {
if (options.debug) {
......@@ -18,57 +23,29 @@ module.exports = function (options = {}) {
var authstatus;
var topic = req.body.topic;
var cachekey = 'pub:' + req.body.client_id + ':' + req.body.username + ':' + topic;
var cachekey = 'pub:'+req.body.client_id +':'+ req.body.username+':'+topic;
var authstatus = cache.get(cachekey);
if (typeof (authstatus) === 'undefined') {
cache.set(cachekey, true); // cache missed
}
var response
var decoded = require('jwt-verify').verify(req.body.username).res
if (decoded) {
if (decoded.role === 'realtimedb') response = { 'result': 'ok' }
else response = { 'result': 'no' }
res.send(response);
next();
if (typeof(authstatus)=='undefined') {
// cache missed
authCheck(req.body.client_id, req.body.username, topic, function(result) {
cache.set(cachekey, result);
res.send({
"result": result?"ok":"no"
});
});
}
else {
var GGID = require('./utils/getGroupID');
var output = {};
GGID.getGroupID(req.body.username, req.body.client_id, function (group) {
if (group) {
var _ftopic = require('./utils/router').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
response = {
'result': 'ok',
'modifiers': {
'topic': _ftopic,
'qos': 0,
'retain': false
}
}
if (options.debug) {
console.log(response);
}
if (output.verb == 'get' || output.verb == 'read') {
response.modifiers.payload = Buffer.from(req.body.client_id).toString('base64');
res.send({
"result": authstatus?"ok":"no"
});
}
res.send(response);
next();
}
else {
res.send({ "result": "no" });
next();
}
res.send({
"result": "no"
});
}
}
else {
res.send({ "result": "no" });
next();
}
}
......
var validator = require('./validator');
var config = require('config');
// var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('device_registry_port'), host: config.get('device_registry_host') });
var seneca = require('seneca')({ log: 'silent' }).client({ port: config.get('token_registry_port'), host: config.get('token_registry_host') });
// https://github.com/isaacs/node-lru-cache
var LRU = require("lru-cache"),
var LRU = require("lru-cache") ,
cache = LRU({
max: 500,
maxAge: 1000 * 60 * 5
});
var debug = false;
// var authclient = require('seneca')({ log: 'silent' })
// .client({ port: config.get('authserv_port'), host: config.get('authserv_host') });
var authclient = require('seneca')({log: 'silent'})
.client({port: config.get('authserv_port'), host: config.get('authserv_host')});
// for testing
function authCheck(client_id, token, password, callback) {
const util = require('util')
// console.log(util.inspect(myObject, false, null, true));
// console.log('jwt-result:' + util.inspect(require('jwt-verify').verify(token), false, null, true))
if (require('jwt-verify').verify(token).res) { // auth realtimedb by token
authclient.act({role:'auth',cmd:'token',action:'info',token: token}, function(err, res) {
if (res && res.data) {
callback(true);
}
else {
console.log('token :' + token)
seneca.act('ms:tokenregistry, cmd:getAttributes, type:device, tokencode:' + token, function (err, res) {
console.log('result : ' + util.inspect(res.result, false, null, true))
if (res.result) {
var token_profile = (res && res.result && res.result[0]) ? res.result[0] : {};
var mqttauth = {
clientid: client_id,
token: token,
password: password
};
console.log(util.inspect(validator.auth_connect(mqttauth, token_profile), false, null, true))
callback(validator.auth_connect(mqttauth, token_profile).status);
}
else {
callback(false);
}
});
// seneca.act('cmd:getAccessTokenInfo, tokencode:'+token, function(err,res) {
// if (!err && res) {
// var token_profile = (res&&res.result&&res.result[0])?res.result[0]:{};
// var mqttauth = {
// clientid : client_id,
// token : token,
// password : password
// };
// callback( validator.auth_connect(mqttauth, token_profile) );
// }
// else {
// callback(false);
// }
// });
// authclient.act({ role: 'auth', cmd: 'token', action: 'info', token: token }, function (err, res) { // auth client device by query from db
// if (debug) {
// console.log("res ------>\n");
// console.log(res);
// }
// if (res && res.data) {
// try {
// var jdata = JSON.parse(res.data);
// if (jdata && jdata.code == 200) {
// callback(true);
// }
// else callback(false);
// } catch (e) {
// callback(false);
// }
// callback(true);
// }
// else {
// callback(false);
// }
// });
}
}
module.exports = function (options = {}) {
debug = options.debug || false;
return function (req, res, next) {
module.exports = function(options={}) {
return function(req, res, next) {
if (req.header('vernemq-hook') == 'auth_on_register' && req && req.body) {
if (debug) {
if (options.debug) {
console.log('auth_on_register-------------');
console.log(req.body);
}
var cachekey = 'auth:' + req.body.client_id + ':' + req.body.username + ':' + req.body.password;
var cachekey = 'auth:'+req.body.client_id +':'+ req.body.username +':'+ req.body.password;
var authstatus = cache.get(cachekey);
if (typeof (authstatus) == 'undefined') {
if (typeof(authstatus)=='undefined') {
// cache missed
authCheck(req.body.client_id, req.body.username, req.body.password, function (result) {
authCheck(req.body.client_id, req.body.username, req.body.password, function(result) {
cache.set(cachekey, result);
res.send({
"result": result ? "ok" : "no"
"result": result?"ok":"no"
});
});
}
else {
res.send({
"result": authstatus ? "ok" : "no"
"result": authstatus?"ok":"no"
});
}
next();
......
var config = require('config');
// https://github.com/isaacs/node-lru-cache
var LRU = require("lru-cache"),
var LRU = require("lru-cache") ,
cache = LRU({
max: 500,
maxAge: 1000 * 60 * 5
});
module.exports = function (options = {}) {
return function (req, res, next) {
// for testing
function authCheck(client_id, token, topic, callback) {
callback(true);
}
module.exports = function(options={}) {
return function(req, res, next) {
if (req.header('vernemq-hook') == 'auth_on_subscribe' && req && req.body) {
if (options.debug) {
console.log('auth_on_subscribe-------------');
console.log(req.body);
}
if (req.header('vernemq-hook') == 'auth_on_subscribe' && req && req.body) {
var authstatus;
var topic = req.body.topics[0].topic;
var cachekey = 'sub:' + req.body.client_id + ':' + req.body.username + ':' + topic;
var cachekey = 'sub:'+req.body.client_id +':'+ req.body.username+':'+topic;
var authstatus = cache.get(cachekey);
if (typeof (authstatus) == 'undefined') {
cache.set(cachekey, true); // cache missed
}
var response
var decoded = require('jwt-verify').verify(req.body.username).res
if (decoded) {
if (decoded.role === 'realtimedb') response = { 'result': 'ok' }
else response = { 'result': 'no' }
res.send(response);
next();
if (typeof(authstatus)=='undefined') {
// cache missed
authCheck(req.body.client_id, req.body.username, topic, function(result) {
cache.set(cachekey, result);
res.send({
"result": result?"ok":"no"
});
});
}
else {
var GGID = require('./utils/getGroupID');
GGID.getGroupID(req.body.username, req.body.client_id, function (group) {
if (group) {
var _ftopic = require('./utils/router').rewriteTopic(topic, 'sub', group, req.body.client_id) // get topic where concat with groupID
var _topic = [{ // setTopic for response
'topic': _ftopic,
'qos': 0
}]
response = {
'result': 'ok',
'topics': _topic
}
if (options.debug) {
console.log(response);
res.send({
"result": authstatus?"ok":"no"
});
}
res.send(response);
next();
}
else {
res.send({ "result": "no" });
next();
}
res.send({
"result": "no"
});
}
}
else {
res.send({ "result": "no" });
next();
}
}
......
{
"authserv_host" : "AUTH_SERVICE_HOST",
"authserv_port" : "AUTH_SERVICE_PORT",
"device_registry_host" : "DEVICE_REGISTRY_HOST",
"device_registry_port" : "DEVICE_REGISTRY_PORT",
"token_registry_host" : "TOKEN_REGISTRY_HOST",
"token_registry_port" : "TOKEN_REGISTRY_PORT",
"auth_on_register_debug" : "AUTH_ON_REGISTER_DEBUG",
"auth_on_publish_debug" : "AUTH_ON_PUBLISH_DEBUG",
"auth_on_subscribe_debug" : "AUTH_ON_SUBSCRIBE_DEBUG",
"on_publish_debug" : "ON_PUBLISH_DEBUG",
"on_deliver_debug" : "ON_DELIVER_DEBUG",
"on_unsubscribe_debug" : "ON_UNSUBSCRIBE_DEBUG",
"on_offline_debug" : "ON_OFFLINE_DEBUG"
"authserv_port" : "AUTH_SERVICE_PORT"
}
{
"device_registry_host" : "127.0.0.1",
"device_registry_port" : 8990,
"auth_on_register_debug" : false,
"auth_on_publish_debug" : false,
"auth_on_subscribe_debug" : false,
"on_publish_debug" : false,
"on_deliver_debug" : false,
"on_unsubscribe_debug" : false,
"on_offline_debug" : false
}
{
"authserv_host" : "203.151.51.4",
"authserv_port" : 31081,
"pubca": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0oW2b1az7MLTRBQojy8e\nYTmVUcbrHBykyMZCkwt4OdL/4zD6jhOmE9JMr3NfRxEJ2BVj7gasEH2h/mpNRtSK\nHjKsgmFWt22QR/TNwNu7AHUiu+7pxyeOz6IDW9bzrptwwwvFz8wc0oKah6fs0cNY\n/Ln5QwY5CWpGJmHF5BOFE5R9PjC3bY2roKwDbKiw4Kx1rbRxwbSzvFGtBMVyK0Rv\nJpWEN6wTEesAI/bLkPth712zfY/PXFi9Vei/gcLxptceISj/o+PUZm4F6u+rHGGt\nOlcBI8lKiCBO8bggmGgpGCZ1fomj5pOPfInl/6Nn4X0gk/4s0MB7zuhBv45zxF8J\ntbzqQ9TVPdUewMtR5UWoPMGiGt6ZOYRAAmGYSWCsa7hD3plcg0NXYXVuLinyxmgd\nKUv0JmmDqWdkNme9W6m42Jb/zEACcneIIVgUeDkadYaJSjY05d2gn/Vn24f0hqp2\nSQ41fYBxw8eKUJLBNo2c9l+Vz7w/dln4cqI/hatXqOVvLml3CKBGwT9hFjufVTpr\nX5WgDzAxGAl0kO0IucInL/XROezsVcxhyJ2dp44KPOoSIUW8dFz7HNq4t9ENzcPV\nvYfvyS0l00p+ivaqT9iV53Ash6f+tHOR5arTNsuM3DHTi3Fi6qIhXSW5qGUl401c\nzSaVroFHIeQI0ZcTxzAOvS0CAwEAAQ==\n-----END PUBLIC KEY-----",
"device_registry_host" : "127.0.0.1",
"device_registry_port" : 8080
"authserv_host" : "203.154.135.231",
"authserv_port" : 31088
}
{
"device_registry_host" : "alpha.nexpie.io",
"device_registry_port" : 8990,
"token_registry_host" : "alpha.nexpie.io",
"token_registry_port" : 8790,
"auth_on_register_debug" : true,
"auth_on_publish_debug" : true,
"auth_on_subscribe_debug" : true,
"on_publish_debug" : true,
"on_deliver_debug" : true,
"on_unsubscribe_debug" : true,
"on_offline_debug" : true
}
process.env["NODE_ENV"] = "development";
process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
var config = require('config');
var auth_on_register_debug = config.get('auth_on_register_debug');
var auth_on_publish_debug = config.get('auth_on_publish_debug');
var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
var on_publish_debug = config.get('on_publish_debug');
var on_deliver_debug = config.get('on_deliver_debug');
var on_unsubscribe_debug = config.get('on_unsubscribe_debug');
var on_offline_debug = config.get('on_offline_debug');
var restify = require('restify');
var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_debug });
var auth_on_publish = require('./auth_on_publish')({ debug: auth_on_publish_debug });
var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscribe_debug });
var on_publish = require('./on_publish')({ debug: on_publish_debug });
var on_deliver = require('./on_deliver')({ debug: on_deliver_debug });
var on_unsubscribe = require('./on_unsubscribe')({ debug: on_unsubscribe_debug });
var on_offline = require('./on_offline')({ debug: on_offline_debug });
var auth_on_register = require('./auth_on_register')({debug:true});
var auth_on_publish = require('./auth_on_publish')({debug:true});
var auth_on_subscribe = require('./auth_on_subscribe')({debug:true});
var on_publish = require('./on_publish')({debug:true});
const server = restify.createServer({
name: 'authhook',
version: '1.0.1',
version: '1.0.0',
});
const port = 40000;
......@@ -39,15 +28,7 @@ server.get('/about', function (req, res, next) {
server.post('/authreg', auth_on_register);
server.post('/authpub', auth_on_publish);
server.post('/authsub', auth_on_subscribe);
server.post('/onsub', (req, res, next) => {
console.log(req.body)
res.send('')
})
server.post('/onunsub', on_unsubscribe)
server.post('/ondeliver', on_deliver)
server.post('/onpub', on_publish)
server.post('/onoff', on_offline)
server.post('/ongone', on_offline)
server.post('/onpub', on_publish);
server.listen(port, function () {
console.log('%s listening at %s', server.name, server.url);
......
var modify = require('./utils/modify');
module.exports = function(options = {}) {
return function (req, res, next) {
console.log('----on_deliver-----')
var topics = modify.removeTempWordInTopic(req.body.topic)
console.log(req.body)
// console.log(topics)
var response = {
'result': 'ok',
'modifiers': {
"topic": topics
}
}
console.log(response);
res.send(response)
}
module.exports.on_deliver = on_deliver
function joinTopic(topics) {
var topic = topics.split('/!')[1]
return topics.split('/!')[0] + topic.substring(topic.indexOf('/'), topic.length)
}
}
module.exports = function(options = {}) {
return function (req, res, next) {
doRedis()
}
function doRedis() {
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ module.exports = function(options={}) {
console.log('on_publish-------------');
console.log(req.body);
}
console.log(req.body)
var topic = req.body.topic;
var cachekey = 'pub:'+req.body.client_id +':'+ req.body.username+':'+topic;
......
module.exports = function(options = {}) {
return function (req, res, next) {
console.log('------on unsubscribe-------')
console.log(req.body)
var topic = req.body.topics[0];
var token = req.body.username
var client_id = req.body.client_id
var response
var decoded = require('jwt-verify').verify(token).res
if (decoded) {
if (decoded.role === 'realtimedb') {
response = { 'result': 'ok' }
}
else response = { 'result': 'no' }
res.send(response);
next()
}
else {
var GGID = require('./utils/getGroupID');
GGID.getGroupID(token, client_id, function(group) {
if (group) {
var _ftopic = require('./utils/router').rewriteTopic(topic, 'unsub', group, client_id)
response = {
"result": "ok",
"topics": [_ftopic]
}
}
else response = { 'result': 'no' }
if (options.debug) {
console.log('on_unsubscribe-------------');
console.log(response);
}
res.send(response);
next()
});
}
}
}
......@@ -33,13 +33,13 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"optional": true
},
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"optional": true,
"requires": {
"tweetnacl": "^0.14.3"
}
......@@ -56,22 +56,12 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
},
"bunyan": {
"version": "1.8.12",
"resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.12.tgz",
......@@ -83,16 +73,11 @@
"safe-json-stringify": "~1"
}
},
"commander": {
"version": "2.15.1",
"resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"optional": true
},
"config": {
"version": "1.31.0",
......@@ -157,12 +142,6 @@
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz",
"integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw=="
},
"diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true
},
"dtrace-provider": {
"version": "0.8.7",
"resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.7.tgz",
......@@ -176,20 +155,11 @@
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"optional": true,
"requires": {
"jsbn": "~0.1.0",
"safer-buffer": "^2.1.0"
}
},
"ecdsa-sig-formatter": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz",
"integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"eraro": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/eraro/-/eraro-1.0.0.tgz",
......@@ -203,12 +173,6 @@
"resolved": "https://registry.npmjs.org/escape-regexp-component/-/escape-regexp-component-1.0.2.tgz",
"integrity": "sha1-nGO20LJf8qiMOtvRjFthrMO5+qI="
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"ewma": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/ewma/-/ewma-2.0.1.tgz",
......@@ -228,9 +192,9 @@
"integrity": "sha512-WQSYVKn6tDW/3htASeUkrx5LcnuTENQIZQPCVlwdnvIJ7bYtSpoJYq38MgUJnx1CQIR1gjZ8HJxAEcN4gqugBg=="
},
"find-my-way": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-1.15.2.tgz",
"integrity": "sha512-mngORPD+dxVhaZWB3nv2VE4J7ch1Mm4VcwNuYnixgZeHMfJujbOJ6CCWxDdI41WS4MykPYUA3aTCyux60sy4VQ==",
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-1.16.0.tgz",
"integrity": "sha512-Y9nEAVrgi33SJIGpzITdKQ0Z784/mqLzP7Y5r2Q0hTTXnrvoQJW9cYpt1JiOhFOQfwvxM4/LulwfGIWpugrBkA==",
"requires": {
"fast-decode-uri-component": "^1.0.0",
"safe-regex": "^1.1.0",
......@@ -242,12 +206,6 @@
"resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz",
"integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg=="
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"gate-executor": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/gate-executor/-/gate-executor-1.1.1.tgz",
......@@ -282,32 +240,14 @@
"path-is-absolute": "^1.0.0"
}
},
"growl": {
"version": "1.10.5",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
"integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
"dev": true
},
"handle-thing": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz",
"resolved": "http://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz",
"integrity": "sha1-/Xqtcmvxpf0W38KbL3pmAdJxOcQ="
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"hoek": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz",
"resolved": "http://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz",
"integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA=="
},
"hpack.js": {
......@@ -340,6 +280,7 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"optional": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
......@@ -358,8 +299,7 @@
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
"optional": true
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
"json-schema": {
"version": "0.2.3",
......@@ -373,39 +313,16 @@
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"resolved": "http://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"requires": {
"minimist": "^1.2.0"
}
},
"jsonic": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/jsonic/-/jsonic-0.3.0.tgz",
"integrity": "sha1-tUXalfVDkuWLPdoF9fLjd6bJ0b8="
},
"jsonwebtoken": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.3.0.tgz",
"integrity": "sha512-oge/hvlmeJCH+iIz1DwcO7vKPkNGJHhgkspk8OH3VKlw+mbi42WtD4ig1+VXRln765vxptAv+xT26Fd3cteqag==",
"requires": {
"jws": "^3.1.5",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1"
},
"dependencies": {
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
}
}
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/jsonic/-/jsonic-0.3.1.tgz",
"integrity": "sha512-5Md4EK3vPAMvP2sXY6M3/vQEPeX3LxEQBJuF979uypddXjsUlEoAI9/Nojh8tbw+YU5FjMoqSElO6oyjrAuprw=="
},
"jsprim": {
"version": "1.4.1",
......@@ -418,92 +335,20 @@
"verror": "1.10.0"
}
},
"jwa": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.6.tgz",
"integrity": "sha512-tBO/cf++BUsJkYql/kBbJroKOgHWEigTKBAjjBEmrMGYd1QMBC74Hr4Wo2zCZw6ZrVhlJPvoMrkcOnlWR/DJfw==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.10",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.1.5.tgz",
"integrity": "sha512-GsCSexFADNQUr8T5HPJvayTjvPIfoyJPtLQBwn5a4WZQchcrPMPMAWcC1AzJVRDKyD6ZPROPAxgv6rfHViO4uQ==",
"requires": {
"jwa": "^1.1.5",
"safe-buffer": "^5.0.1"
}
},
"jwt-verify": {
"version": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git#c9692da3fd11464e9270acd0c47f289648119ec9",
"from": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git",
"requires": {
"config": "^2.0.1",
"jsonwebtoken": "^8.3.0"
},
"dependencies": {
"config": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/config/-/config-2.0.1.tgz",
"integrity": "sha512-aTaviJnC8ZjQYx8kQf4u6tWqIxWolyQQ3LqXgnCLAsIb78JrUshHG0YuzIarzTaVVe1Pazms3TXImfYra8UsyQ==",
"requires": {
"json5": "^1.0.1"
}
}
}
},
"lodash": {
"version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8="
},
"lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY="
},
"lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M="
},
"lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
},
"lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
},
"lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE="
},
"lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
},
"lru-cache": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz",
"integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==",
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
"requires": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
......@@ -523,6 +368,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -534,8 +380,9 @@
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"optional": true,
"requires": {
"minimist": "0.0.8"
},
......@@ -543,58 +390,15 @@
"minimist": {
"version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
}
},
"mocha": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
"integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
"dev": true,
"requires": {
"browser-stdout": "1.3.1",
"commander": "2.15.1",
"debug": "3.1.0",
"diff": "3.5.0",
"escape-string-regexp": "1.0.5",
"glob": "7.1.2",
"growl": "1.10.5",
"he": "1.1.1",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"supports-color": "5.4.0"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"optional": true
}
}
},
"moment": {
"version": "2.22.2",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.23.0.tgz",
"integrity": "sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA==",
"optional": true
},
"ms": {
......@@ -614,14 +418,14 @@
}
},
"nan": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.11.0.tgz",
"integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw==",
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz",
"integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==",
"optional": true
},
"ncp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
"resolved": "http://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
"integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=",
"optional": true
},
......@@ -675,8 +479,9 @@
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
"resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"optional": true
},
"patrun": {
"version": "1.0.0",
......@@ -708,13 +513,13 @@
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM="
},
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.6.0.tgz",
"integrity": "sha512-KIJqT9jQJDQx5h5uAVPimw6yVg2SekOKu959OCtktD3FjzbpvaPr8i4zzg07DOMz+igA4W/aNM7OV8H37pFYfA=="
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"requires": {
"core-util-is": "~1.0.0",
......@@ -735,9 +540,9 @@
}
},
"restify": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/restify/-/restify-7.2.1.tgz",
"integrity": "sha512-xygVfQn/FiyzSPNIiOlzos6+RVcmTTK/bN0/m4z6vQwUY1yXntAsXM8ckq6hMxYfkhZfbPMM5hvBf75B8zLE1g==",
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/restify/-/restify-7.3.0.tgz",
"integrity": "sha512-jXJyT8lGKHfcOxmD3Rc9ftF2fwpw7BzaUwVdEbolsoehAs0ZCqEUc55kmw0pxzBSNK7kQydo5/ata2t9ZrOBuQ==",
"requires": {
"assert-plus": "^1.0.0",
"bunyan": "^1.8.12",
......@@ -781,7 +586,7 @@
},
"rimraf": {
"version": "2.4.5",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz",
"resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz",
"integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=",
"optional": true,
"requires": {
......@@ -806,7 +611,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"requires": {
"ret": "~0.1.10"
......@@ -823,9 +628,9 @@
"integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo="
},
"semver": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz",
"integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw=="
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
},
"semver-store": {
"version": "0.3.0",
......@@ -855,6 +660,18 @@
"seneca-transport": "2.3",
"use-plugin": "1.0",
"wreck": "12.5"
},
"dependencies": {
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"semver": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz",
"integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw=="
}
}
},
"seneca-transport": {
......@@ -873,6 +690,13 @@
"qs": "6.5",
"reconnect-core": "1.3",
"wreck": "12.5"
},
"dependencies": {
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
}
}
},
"spdy": {
......@@ -889,9 +713,9 @@
}
},
"spdy-transport": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/spdy-transport/-/spdy-transport-2.1.0.tgz",
"integrity": "sha512-bpUeGpZcmZ692rrTiqf9/2EUakI6/kXX1Rpe0ib/DyOzbiexVfXkw6GnvI9hVGvIwVaUhkaBojjCZwLNRGQg1g==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/spdy-transport/-/spdy-transport-2.1.1.tgz",
"integrity": "sha512-q7D8c148escoB3Z7ySCASadkegMmUZW8Wb/Q1u0/XBgDKMO880rLQDj8Twiew/tYi7ghemKUi/whSYOwE17f5Q==",
"requires": {
"debug": "^2.6.8",
"detect-node": "^2.0.3",
......@@ -911,9 +735,9 @@
}
},
"sshpk": {
"version": "1.14.2",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz",
"integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=",
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz",
"integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==",
"requires": {
"asn1": "~0.2.3",
"assert-plus": "^1.0.0",
......@@ -933,35 +757,25 @@
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
},
"through2": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
"integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"requires": {
"readable-stream": "^2.1.5",
"readable-stream": "~2.3.6",
"xtend": "~4.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
"optional": true
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
},
"use-plugin": {
"version": "1.0.2",
......@@ -973,14 +787,6 @@
"norma": "0.4"
}
},
"util": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/util/-/util-0.11.0.tgz",
"integrity": "sha512-5n12uMzKCjvB2HPFHnbQSjaqAa98L5iIXmHrZCLavuZVe0qe/SJGbDGWlpaHk5lnBkWRDO+dRu1/PgmUYKPPTw==",
"requires": {
"inherits": "2.0.3"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......
......@@ -4,21 +4,14 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "mocha"
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"config": "^1.30.0",
"jsonwebtoken": "^8.3.0",
"jwt-verify": "git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git",
"lru-cache": "^4.1.3",
"restify": "^7.1.1",
"seneca": "^3.6.0",
"util": "^0.11.0"
},
"devDependencies": {
"mocha": "^5.2.0"
"seneca": "^3.6.0"
}
}
REGISTRY_HOST=dock.nexpie.com
GROUPNAME=stack
PROJECTNAME=vernemq/authhook
RELEASE=1.0.0
RELEASE=1.0.1kb
var assert = require('assert')
var getTopic = require('../utils/router').rewriteTopic
describe('GetTopic', () => {
describe('realtime msg', () => {
it('should return topic that id_group have insert between @msg and topic', () => {
var topic = '@msg/any/light'
var id_group = 'bulb'
var tgConcat = '@msg/!bulb/any/light'
var _topic = getTopic(topic, id_group)
assert.equal(_topic, tgConcat)
})
})
describe('shadow', () => {
describe('update pub', () => {
it('should return topic that id have insert between @shadow/update and topic', () => {
var topic = '@shadow/update/any/light'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@shadow/update/!d4484cdb-a47a-4936-bcfd-33c1af39b857/any/light'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
describe('update sub', () => {
it('should return topic that id have insert behind @shadow/updated', () => {
var topic = '@shadow/updated'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@shadow/updated/!d4484cdb-a47a-4936-bcfd-33c1af39b857'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
describe('get pub', () => {
it('should return topic that id have insert between @shadow/get and topic', () => {
var topic = '@shadow/get/any/light'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@shadow/get/!d4484cdb-a47a-4936-bcfd-33c1af39b857/any/light'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
describe('get sub', () => {
it('should return topic that id have insert between @client and #', () => {
var topic = '@client/#'
var id = 'd4484cdb-a47a-4936-bcfd-33c1af39b857'
var tgConcat = '@client/!d4484cdb-a47a-4936-bcfd-33c1af39b857/#'
var _topic = getTopic(topic, id)
assert.equal(_topic, tgConcat)
})
})
})
})
module.exports.getGroupID = getGroupID
var config = require('config');
var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('device_registry_port'), host: config.get('device_registry_host') });
// var getRole = require('../checkClientRole').getRole
function getGroupID(token, client_id, callback) {
var role = require('jwt-verify').verify(token).res
if (role && role.hasOwnProperty('groupId')) {
callback(role.groupId);
}
else {
doDB(client_id, function(group) {
callback(group);
});
}
}
function doDB(client_id, callback) {
seneca.act('cmd:getGroupByClientid, clientid:'+client_id, function(err, res) {
if (err) callback(null);
else callback((res && res.result &&res.result[0])?res.result[0]:null);
});
}
module.exports.insertWordIntoTopic = insertWordIntoTopic
module.exports.removeTempWordInTopic = removeTempWordInTopic
module.exports.replaceWords = replaceWords
module.exports.cleanUpTopic = cleanUpTopic
/*
Ex: insertWordIntoTopic('@shadow/home/temp', '!GROUP', 1)
expected return : "@shadow/!GROUP/home/temp"
*/
function insertWordIntoTopic(topic, word, pos) {
var a = topic.split('/');
a.splice(pos, 0, word);
// console.log('>>> insertWordIntoTopic('+topic +','+ word +','+ pos +');');
// console.log(a.join('/'));
return a.join('/');
}
/*
Ex : removeTempWordInTopic('@shadow/!GROUP/home/temp')
expected return : "@shadowhome/temp"
*/
function removeTempWordInTopic(topic) {
var a = topic.split('/');
var k=0, l=a.length;
while (k<l) {
if (a[k].substr(0,1)=='!') {
a.splice(k,1);
l--;
}
else k++;
}
return a.join('/');
}
function replaceWords(topic, word, from, to) {
var a = topic.split('/');
a.splice(from,to-from+1);
if (word != null) a.splice(from, 0, word);
return a.join('/');
}
// Sample
// var str = insertWordIntoTopic('@shadow/home/temp', '!GROUP', 0);
// console.log(str);
// console.log(removeTempWordInTopic(str));
//console.log(replaceWords('@shadow/set/home/bob/bedroom/temp', 'CLIENTID-XXXXX', 2, 3));
function cleanUpTopic(topic) {
topic = topic.trim();
if (topic.substr(-1)=='/') return topic.slice(-1);
}
var modify = require('./modify');
function rewriteTopic(topic, op, groupid, clientid, output) {
var chunk = topic.split('/');
switch (chunk[0]) {
case '@msg' :
return modify.insertWordIntoTopic(topic, '!'+groupid, 1);
case '@shadow' :
if (chunk[1] == 'set' || chunk[1] == 'overset' || chunk[1] == 'get') {
output.verb = chunk[1];
return modify.insertWordIntoTopic(topic, ''+clientid, 2);
}
else if (chunk[1] == 'write' || chunk[1] == 'overwrite' || chunk[1] == 'read') {
output.verb = chunk[1];
return modify.insertWordIntoTopic(topic, groupid, 2);
}
else if (chunk[1] == 'changed') {
if (op == 'pub') {
if ( chunk.length > 2 )
return modify.insertWordIntoTopic(topic, '!'+groupid, 2);
else if ( chunk.length == 2 )
return modify.insertWordIntoTopic(topic, '!'+clientid, 2);
else return "";
}
else {
if ( chunk.length > 2 )
return modify.insertWordIntoTopic(topic, '!'+groupid, 2);
else if ( chunk.length == 2 )
return modify.insertWordIntoTopic(topic, '!'+clientid, 2);
else return "";
}
}
else return "";
case '@private' :
return modify.insertWordIntoTopic(topic, '!'+clientid, 1);
}
}
module.exports.rewriteTopic = rewriteTopic
module.exports.auth_connect = auth_connect
/*
{ _key: '1196651',
_id: 'access_token/1196651',
_rev: '_XdtTzQK--_',
"type": "v1",
"code": "f2a05d9a420e141d2d268b0c41f2af8e",
"device": "bd2w9fkc-bobclient",
"scope": [
"w:@shadow/read",
"w:@shadow/write"
],
"iat": 1537502874269,
"nbf": 1537502874269,
"exp": 1537609874269,
"for": [
{
"clientid": "bd2w9fkc-bobclient",
"verify": false
}
],
"user": "nexpie"
}
*/
function auth_connect(mqttauth, token_profile) {
var dateNow = Math.floor(Date.now() / 1000)
var res = {
status : true
}
if (token_profile) {
if (token_profile.for) {
var found = false;
for (var i=0; i<token_profile.for.length; i++) {
if (token_profile.for[i].clientid == mqttauth.clientid) {
found = true;
break;
}
}
if (!found) return {status: false, reason: 'uneligible'};
}
if (dateNow > token_profile.exp) return {status: false, reason: 'expired'};
if (token_profile.nbf && (dateNow < token_profile.nbf)) return {status: false, reason: 'uneligible'};
return {status: true};
}
else return false;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment