remove Nopt object
and just export directly
This commit is contained in:
parent
5221c05ac9
commit
190d29070c
28
lib/notp.js
28
lib/notp.js
@ -2,16 +2,6 @@
|
||||
var crypto = require('crypto');
|
||||
var base32 = require('thirty-two');
|
||||
|
||||
|
||||
/*
|
||||
* Export module as new Notp instance
|
||||
*/
|
||||
module.exports = new Notp();
|
||||
|
||||
function Notp() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check a One Time Password based on a counter.
|
||||
*
|
||||
@ -45,7 +35,7 @@ function Notp() {
|
||||
* be user specific, and be incremented for each request.
|
||||
*
|
||||
*/
|
||||
Notp.prototype.checkHOTP = function(args, err, cb) {
|
||||
module.exports.checkHOTP = function(args, err, cb) {
|
||||
|
||||
var hmac,
|
||||
digest,
|
||||
@ -113,7 +103,7 @@ Notp.prototype.checkHOTP = function(args, err, cb) {
|
||||
* Default - 30
|
||||
*
|
||||
*/
|
||||
Notp.prototype.checkTOTP = function(args, err, cb) {
|
||||
module.exports.checkTOTP = function(args, err, cb) {
|
||||
|
||||
var hmac,
|
||||
digest,
|
||||
@ -178,7 +168,7 @@ Notp.prototype.checkTOTP = function(args, err, cb) {
|
||||
* be user specific, and be incremented for each request.
|
||||
*
|
||||
*/
|
||||
Notp.prototype.getHOTP = function(args, err, cb) {
|
||||
module.exports.getHOTP = function(args, err, cb) {
|
||||
|
||||
var hmac,
|
||||
digest,
|
||||
@ -213,7 +203,7 @@ Notp.prototype.getHOTP = function(args, err, cb) {
|
||||
* Default - 30
|
||||
*
|
||||
*/
|
||||
Notp.prototype.getTOTP = function(args, err, cb) {
|
||||
module.exports.getTOTP = function(args, err, cb) {
|
||||
var hmac,
|
||||
digest,
|
||||
offset, h, v, p = 6, b,
|
||||
@ -255,7 +245,7 @@ Notp.prototype.getTOTP = function(args, err, cb) {
|
||||
*
|
||||
* Returns: Base 32 encoded string
|
||||
*/
|
||||
Notp.prototype.encBase32 = function(str) {
|
||||
module.exports.encBase32 = function(str) {
|
||||
return base32.encode(str);
|
||||
};
|
||||
|
||||
@ -269,7 +259,7 @@ Notp.prototype.encBase32 = function(str) {
|
||||
*
|
||||
* Returns: ASCII string
|
||||
*/
|
||||
Notp.prototype.decBase32 = function(b32) {
|
||||
module.exports.decBase32 = function(b32) {
|
||||
return base32.decode(b32);
|
||||
};
|
||||
|
||||
@ -292,7 +282,7 @@ Notp.prototype.decBase32 = function(b32) {
|
||||
*
|
||||
* Returns - truncated HMAC
|
||||
*/
|
||||
Notp.prototype._calcHMAC = function(K, C) {
|
||||
module.exports._calcHMAC = function(K, C) {
|
||||
|
||||
var hmac = crypto.createHmac('SHA1', new Buffer(K)),
|
||||
digest,
|
||||
@ -329,7 +319,7 @@ Notp.prototype._calcHMAC = function(K, C) {
|
||||
*
|
||||
* Returns - byte array
|
||||
*/
|
||||
Notp.prototype._intToBytes = function(num) {
|
||||
module.exports._intToBytes = function(num) {
|
||||
var bytes = [],
|
||||
i;
|
||||
|
||||
@ -351,7 +341,7 @@ Notp.prototype._intToBytes = function(num) {
|
||||
*
|
||||
* Returns - byte array
|
||||
*/
|
||||
Notp.prototype._hexToBytes = function(hex) {
|
||||
module.exports._hexToBytes = function(hex) {
|
||||
for(var bytes = [], c = 0; c < hex.length; c += 2)
|
||||
bytes.push(parseInt(hex.substr(c, 2), 16));
|
||||
return bytes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user