Socket
Socket
Sign inDemoInstall

yub

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.11.0 to 0.11.1

6

lib/yub.js

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

var qs = require('querystring');
var NODE_ENV = process.env.NODE_ENV;

@@ -86,4 +85,4 @@ // List of valid servers. We go through them in round-robin fashion.

// Choose a server in round-robin fashion. First offset is random.
var server = servers[currentServerIdx++];
if (NODE_ENV === 'test') server = servers[0]; // For mocking with nock
currentServerIdx = (currentServerIdx + 1) % servers.length;
var server = servers[currentServerIdx];
var uri = 'https://' + server + '/wsapi/2.0/verify';

@@ -221,1 +220,2 @@ var fullURI = uri + '?' + qs.stringify(params);

Yub._calculateStringToHash = calculateStringToHash; // for tests
Yub._servers = servers; // for tests
{
"name": "yub",
"version": "0.11.0",
"version": "0.11.1",
"description": "Yubico Yubikey API Client for Node.js",

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

@@ -38,3 +38,3 @@ 'use strict';

// Fake the request
nock('https://api.yubico.com')
nock(/https:\/\/api[2-5]?\.yubico\.com/)
.get(pathMatcher)

@@ -74,2 +74,35 @@ .reply(200, function(uri, _requestBody) {

it('should round-robin through servers', function(done) {
var otp = 'cffcccdebcntbilunkhgvehfuigcljjtudrfhgikcirl';
var received = [];
var servers = yub._servers;
// Go around twice to ensure round-robin works
for (var i = 0; i < servers.length * 2; i++) {
req(i, function(err, data) {
assert(err === null);
received.push(data);
if (received.length === servers.length * 2) {
assert(received.slice().sort().toString() === servers.concat(servers).sort().toString());
done();
}
});
}
function req(idx, finished) {
// Fake the request
nock(/https:\/\/api[2-5]?\.yubico\.com/)
.get(/.*/)
.reply(200, function(uri, _requestBody) {
return 'host=' + this.req.headers.host;
});
yub.verify(otp, function(err, data) {
finished(err, data.host);
});
}
});
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc