Comparing version 0.2.0 to 0.2.1
36
index.js
@@ -30,2 +30,3 @@ var request = require('request'); | ||
}, | ||
json: true, | ||
jar: false, | ||
@@ -36,3 +37,3 @@ strictSSL: true | ||
if(res.statusCode === 200) { | ||
callback(null, JSON.parse(body)); | ||
callback(null, body); | ||
} else { | ||
@@ -53,2 +54,3 @@ callback(body); | ||
}, | ||
json: true, | ||
jar: false, | ||
@@ -83,2 +85,3 @@ strictSSL: true | ||
qs: qs, | ||
json: true, | ||
jar: false, | ||
@@ -89,5 +92,5 @@ strictSSL: true | ||
if (res.statusCode === 200) { | ||
callback(null, toJSON(body)); | ||
callback(null, body); | ||
} else { | ||
callback(toJSON(body)); | ||
callback(body); | ||
} | ||
@@ -114,2 +117,3 @@ } else { | ||
qs: qs, | ||
json: true, | ||
jar: false, | ||
@@ -120,3 +124,3 @@ strictSSL: true | ||
if (res.statusCode === 200) { | ||
callback(null, toJSON(body)); | ||
callback(null, body); | ||
} else { | ||
@@ -145,2 +149,3 @@ callback(body); | ||
qs: qs, | ||
json: true, | ||
jar: false, | ||
@@ -151,3 +156,3 @@ strictSSL: true | ||
if (res.statusCode === 200) { | ||
callback(null, toJSON(body)); | ||
callback(null, body); | ||
} else { | ||
@@ -161,22 +166,1 @@ callback(body); | ||
}; | ||
// Utility functions. Should live somewhere else probably. | ||
function isJSON(data) { | ||
if (typeof data === 'object') return true; | ||
try { | ||
data = JSON.parse(data); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function toJSON(data) { | ||
if (typeof data === 'object') return data; | ||
try { | ||
data = JSON.parse(data); | ||
return data; | ||
} catch (e) { | ||
return data; | ||
} | ||
} |
{ | ||
"name": "authy", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Authy.com API lib for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,9 @@ var apikey = "0cd08abec2e9b9641e40e9470a7fc336"; | ||
/* | ||
* Nodeunit swallows uncaught exceptions--get them back! | ||
*/ | ||
process.on('uncaughtException', function(err) { | ||
console.error(err.stack); | ||
}); | ||
/* | ||
* Register New User Tests | ||
@@ -13,2 +20,3 @@ */ | ||
test.ok(res); | ||
test.equal(typeof(res), 'object', 'Response should be an object.'); | ||
test.ok(res.user); | ||
@@ -23,2 +31,3 @@ test_user.id = res.user.id; // Save ID for future tests | ||
test.ok(res); | ||
test.equal(typeof(res), 'object', 'Response should be an object.'); | ||
test.done(); | ||
@@ -29,5 +38,28 @@ }); | ||
exports['Register New User - Blank Email'] = function (test) { | ||
test.done(); | ||
authy.register_user(null, test_user.phone, test_user.country, function (err, res) { | ||
test.ok(err, 'Should get error.'); | ||
test.equal(typeof(err), 'object', 'Error should be an object.'); | ||
test.equal(err.success, false, 'Success should be false.') | ||
test.done(); | ||
}); | ||
}; | ||
exports['Register New User - Blank Phone'] = function (test) { | ||
authy.register_user(test_user.email, null, test_user.country, function (err, res) { | ||
test.ok(err, 'Should get error.'); | ||
test.equal(typeof(err), 'object', 'Error should be an object.'); | ||
test.equal(err.success, false, 'Success should be false.') | ||
test.done(); | ||
}); | ||
}; | ||
exports['Register New User - Invalid Country Code'] = function (test) { | ||
authy.register_user(test_user.email, null, -100, function (err, res) { | ||
test.ok(err, 'Should get error.'); | ||
test.equal(typeof(err), 'object', 'Error should be an object.'); | ||
test.equal(err.success, false, 'Success should be false.') | ||
test.done(); | ||
}); | ||
}; | ||
/* | ||
@@ -39,2 +71,3 @@ * Verify Token Tests | ||
test.ok(res); | ||
test.equal(typeof(res), 'object', 'Response should be an object.'); | ||
test.done(); | ||
@@ -47,2 +80,3 @@ }); | ||
test.ok(res); | ||
test.equal(typeof(res), 'object', 'Response should be an object.'); | ||
test.done(); | ||
@@ -49,0 +83,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10410
241