New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

authy

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authy - npm Package Compare versions

Comparing version 0.2.2 to 0.3.2

165

index.js

@@ -32,5 +32,3 @@ var request = require('request');

request.post({
url: this.apiURL + "/protected/json/users/new",
form: {
this._request("post", "/protected/json/users/new", {
"user[email]": email,

@@ -40,51 +38,22 @@ "user[cellphone]": cellphone,

},
qs: {
api_key: this.apiKey,
send_install_link_via_sms: send_install_link
},
json: true,
jar: false,
strictSSL: true
}, function (err, res, body) {
if (!err) {
if(res.statusCode === 200) {
callback(null, body);
} else {
callback(body);
}
} else {
callback(err);
callback,
{
send_install_link_via_sms: send_install_link
}
});
);
};
Authy.prototype.delete_user = function (id, callback) {
request.post({
url: this.apiURL + "/protected/json/users/delete/" + id,
qs: {
api_key: this.apiKey
},
json: true,
jar: false,
strictSSL: true
}, function (err, res, body) {
if (!err) {
if(res.statusCode === 200) {
callback(null, body);
} else {
callback(body);
}
} else {
callback(err);
}
});
this._request("post", "/protected/json/users/delete/" + id, {}, callback);
};
Authy.prototype.user_status = function (id, callback) {
this._request("get", "/protected/json/users/" + id + "/status", {}, callback);
};
Authy.prototype.verify = function (id, token, force, callback) {
var qs = {
api_key: this.apiKey
};
var qs = {};
if (arguments.length > 3) {
qs.force = force;
qs.force = force;
} else {

@@ -94,25 +63,7 @@ callback = force;

request.get({
url: this.apiURL + "/protected/json/verify/" + token + "/" + id,
qs: qs,
json: true,
jar: false,
strictSSL: true
}, function (err, res, body) {
if (!err) {
if (res.statusCode === 200) {
callback(null, body);
} else {
callback(body);
}
} else {
callback(err);
}
});
this._request("get", "/protected/json/verify/" + token + "/" + id, {}, callback, qs);
};
Authy.prototype.request_sms = function (id, force, callback) {
var qs = {
api_key: this.apiKey
};
var qs = {};

@@ -125,25 +76,7 @@ if (arguments.length > 2) {

request.get({
url: this.apiURL + "/protected/json/sms/" + id,
qs: qs,
json: true,
jar: false,
strictSSL: true
}, function (err, res, body) {
if (!err) {
if (res.statusCode === 200) {
callback(null, body);
} else {
callback(body);
}
} else {
callback(err);
}
});
this._request("get", "/protected/json/sms/" + id, {}, callback, qs);
};
Authy.prototype.request_call = function (id, force, callback) {
var qs = {
api_key: this.apiKey
};
var qs = {};

@@ -156,4 +89,47 @@ if (arguments.length > 2) {

request.get({
url: this.apiURL + "/protected/json/call/" + id,
this._request("get", "/protected/json/call/" + id, {}, callback, qs);
};
Authy.prototype.phones = function() {
self = this;
return {
verification_start: function(phone_number, country_code, via, callback) {
if(arguments.length == 3) {
callback = via;
via = "sms";
}
options = {
phone_number: phone_number,
country_code: country_code,
via: via
};
self._request("post", "/protected/json/phones/verification/start", options, callback);
},
verification_check: function(phone_number, country_code, verification_code, callback) {
options = {
phone_number: phone_number,
country_code: country_code,
verification_code: verification_code
};
self._request("get", "/protected/json/phones/verification/check", options, callback);
},
info: function(phone_number, country_code, callback) {
options = {
phone_number: phone_number,
country_code: country_code
};
self._request("get", "/protected/json/phones/info", options, callback);
}
};
};
Authy.prototype._request = function(type, path, params, callback, qs) {
qs = qs || {}
qs['api_key'] = this.apiKey;
options = {
url: this.apiURL + path,
form: params,
qs: qs,

@@ -163,5 +139,7 @@ json: true,

strictSSL: true
}, function (err, res, body) {
}
var callback_check = function (err, res, body) {
if (!err) {
if (res.statusCode === 200) {
if(res.statusCode === 200) {
callback(null, body);

@@ -174,3 +152,14 @@ } else {

}
});
};
switch(type) {
case "post":
request.post(options, callback_check);
break;
case "get":
request.get(options, callback_check);
break;
}
};
{
"name": "authy",
"version": "0.2.2",
"version": "0.3.2",
"description": "Authy.com API lib for node.js",

@@ -27,3 +27,3 @@ "main": "index.js",

"dependencies": {
"request": "2.39.0"
"request": "2.42.0"
},

@@ -30,0 +30,0 @@ "devDependencies": {

@@ -90,2 +90,46 @@ # node-authy [![Dependency Status](https://david-dm.org/evilpacket/node-authy.png)](https://david-dm.org/evilpacket/node-authy)

Get Registered User Status
--------------------------
user_status(id, callback);
```javascript
authy.user_status('1337', function (err, res) {
});
```
Start Phone Verification
------------------------
phones().verification_start(phone_number, country_code, via, callback);
```javascript
authy.phones().verification_start('111-111-1111', '1', 'sms', function(err, res) {
});
```
Check Phone Verification
------------------------
phones().verification_check(phone_number, country_code, verification_code, callback);
```javascript
authy.phones().verification_check('111-111-1111', '1', '0000', function (err, res) {
});
```
Get Phone Info
------------------------
phones().info(phone_number, country_code, callback);
```javascript
authy.phones().info('111-111-1111-, '1', function (err, res) {
});
```
Additional Contributors

@@ -92,0 +136,0 @@ -----------------------

@@ -131,1 +131,82 @@ var apikey = "0cd08abec2e9b9641e40e9470a7fc336";

};
/*
* Users tests
*/
exports.users = {
status: {
setUp: function(callback) {
authy.register_user(test_user.email, test_user.phone, function(err, res) {
test_user.id = res.user.id;
callback();
});
},
does_not_exists: function(test) {
authy.user_status("tony", 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.equal(err.message, "User not found.");
test.done();
});
},
exists: function(test) {
authy.user_status(test_user.id, function (err, res) {
test.ok(res);
test.equal(typeof(res), 'object', 'res should be an object.');
test.equal(res.success, true, 'Success should be true.')
test.equal(typeof(res.status), 'object');
test.done();
});
}
}
};
/*
* Phone Info tests
*/
exports.phones = {
verification_starts: {
without_via: function (test) {
test.expect(1);
authy.phones().verification_start("111-111-1111", "1",
function (err, res) {
test.ok(res);
test.done();
}
);
},
with_via: function (test) {
test.expect(1);
authy.phones().verification_start("111-111-1111", "1", "sms",
function (err, res) {
test.ok(res);
test.done();
}
);
},
},
verification_check: function (test) {
test.expect(1);
authy.phones().verification_check("111-111-1111", "1", "0000",
function (err, res) {
test.ok(res);
test.done();
}
);
},
info: function (test) {
test.expect(1);
authy.phones().info("7754615609", "1",
function (err, res) {
test.ok(res);
test.done();
}
);
}
}

Sorry, the diff of this file is not supported yet

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