Socket
Socket
Sign inDemoInstall

yub

Package Overview
Dependencies
23
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.10.2 to 0.10.3

39

lib/yub.js

@@ -21,3 +21,3 @@ var crypto = require('crypto');

// Apply here https://upgrade.yubico.com/getapikey/
var init = function(client_id, secretkey) {
var init = function (client_id, secretkey) {
clientID = client_id;

@@ -29,12 +29,11 @@ secretKey = secretkey;

// separated by '='
var parse = function(data) {
var bits = data.split("\r\n");
var retval = {};
for(var i in bits) {
var bit = bits[i];
var kv = bit.split("=", 2);
if(kv[0].length > 0) {
var parse = function (data) {
var obj = data.split("\r\n"),
retval = {};
Object.keys(obj).map(function(key) {
var kv = obj[key].split("=", 2);
if (kv[0].length > 0) {
retval[kv[0]] = kv[1];
}
}
});
return retval;

@@ -47,7 +46,3 @@ };

var len = otp.length;
var identity = null;
if(len > 32) {
identity = otp.substring(0,len - 32);
}
return identity;
return (len > 32) ? otp.substring(0, len - 32) : null;
};

@@ -70,3 +65,3 @@

// according to instructions here: https://code.google.com/p/yubikey-val-server-php/wiki/ValidationProtocolV20
var calculateHmac = function(obj) {
var calculateHmac = function (obj) {
var str = calculateStringToHash(obj);

@@ -81,9 +76,9 @@ var buf = new Buffer(secretKey, 'base64').toString('binary');

// an object in data to work with
var verify = function(otp, callback) {
var verify = function (otp, callback) {
// create 40 character random string
crypto.randomBytes(nonceLength, function(err, buf) {
crypto.randomBytes(nonceLength, function (err, buf) {
// turn it to hex
var nonce = buf.toString('hex').slice(0,40);
var nonce = buf.toString('hex').slice(0, 40);

@@ -104,7 +99,7 @@ // create parameters to send to web service

// to https request
request({ uri: uri, qs: params} , function(err, res, body) {
request({ uri: uri, qs: params} , function (err, res, body) {
// error
if (res.statusCode !== 200) {
return callback(true,null);
return callback(true, null);
}

@@ -119,3 +114,3 @@

var h = calculateHmac(body);
body.signatureVerified = (bodyh === h.replace("=",''));
body.signatureVerified = (bodyh === h.replace("=", ''));

@@ -126,3 +121,3 @@ // check whether the nonce is the same as the one we gave it

// calculate the key's identity
if(typeof body.status != "undefined" && body.status === "OK") {
if (typeof body.status != "undefined" && body.status === "OK") {
body.identity = calculateIdentity(otp);

@@ -129,0 +124,0 @@ }

{
"name": "yub",
"version": "0.10.2",
"version": "0.10.3",
"description": "Yubico Yubikey API Client",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc