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

sa-kws-node-sdk

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sa-kws-node-sdk - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

48

lib/kwsSdk.js

@@ -5,2 +5,3 @@ var BPromise = require('bluebird');

var utils = require('./utils');
var crypto = require('crypto');

@@ -96,3 +97,2 @@ function KwsSdk(opts) {

//*********************************************************************************
// This functions are called when an API call is made

@@ -161,2 +161,48 @@ //*********************************************************************************

//*********************************************************************************
// Webhooks part
//*********************************************************************************
// validate if the call is coming from KWS API
KwsSdk.prototype.validWebhookSignature = function(secretKey) {
var self = this;
return function(req, res, next) {
var signature = req.headers['x-kwsapi-signature'];
if (signature === undefined) {
res.sendStatus('401');
if (self.opts.debug) {
self.opts.logger('Error in: validWebhookSignature middleware');
self.opts.logger('headers[x-kwsapi-signature] is undefined');
}
} else {
var signedData = req.originalUrl;
for(var key in req.body) {
signedData += key;
signedData += data[key];
}
signedData += secretKey;
var currentSignature = crypto.createHmac('sha1', secretKey).update(signedData).digest('hex').toString('base64');
if (currentSignature !== signature) {
res.sendStatus('401');
if (self.opts.debug) {
self.opts.logger('Error in: validWebhookSignature middleware');
self.opts.logger('headers[x-kwsapi-signature] is invalid, check your secretKey');
}
} else {
next();
}
}
}
};
//*********************************************************************************
module.exports = KwsSdk;

2

package.json
{
"name": "sa-kws-node-sdk",
"version": "0.1.4",
"version": "0.1.5",
"description": "KWS Node App SDK",

@@ -5,0 +5,0 @@ "main": "./lib/kwsSdk.js",

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