Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-otp

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-otp - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.nvmrc

4

lib/hotp.d.ts

@@ -0,3 +1,4 @@

/// <reference types="node" />
export interface Parameters {
secret: string;
secret: string | Buffer;
movingFactor?: number;

@@ -7,3 +8,4 @@ codeDigits?: number;

truncationOffset?: number;
hmacAlgorithm?: string;
}
export default function (parameters: Parameters): string;

@@ -34,3 +34,3 @@ "use strict";

function default_1(parameters) {
let { secret, movingFactor, codeDigits, addChecksum, truncationOffset } = parameters;
let { secret, movingFactor, codeDigits, addChecksum, truncationOffset, hmacAlgorithm } = parameters;
if (!secret)

@@ -46,5 +46,6 @@ throw new Error('no secret value');

truncationOffset = -1;
let result;
if (!hmacAlgorithm)
hmacAlgorithm = 'sha1';
const digits = addChecksum ? codeDigits + 1 : codeDigits;
const text = Buffer.alloc(8);
const text = new Buffer(8);
for (let i = text.length - 1; i >= 0; i--) {

@@ -54,5 +55,3 @@ text[i] = movingFactor & 0xff;

}
const hmac = crypto.createHmac('sha1', secret);
hmac.update(text);
const hash = Buffer.from(hmac.digest('hex'), 'hex');
const hash = crypto.createHmac(hmacAlgorithm, secret).update(text).digest();
let offset = hash[hash.length - 1] & 0xf;

@@ -68,3 +67,3 @@ if (0 <= truncationOffset && truncationOffset < hash.length - 4)

otp = otp * 10 + calcChecksum(otp, codeDigits);
result = otp.toString();
let result = otp.toString();
while (result.length < digits)

@@ -71,0 +70,0 @@ result = '0' + result;

@@ -0,3 +1,4 @@

/// <reference types="node" />
export interface Parameters {
secret: string;
secret: string | Buffer;
time?: number;

@@ -8,3 +9,4 @@ timestamp?: number;

truncationOffset?: number;
hmacAlgorithm?: string;
}
export default function (parameters: Parameters): string;

@@ -6,3 +6,3 @@ "use strict";

function default_1(parameters) {
let { secret, time, timestamp, codeDigits, addChecksum, truncationOffset } = parameters;
let { secret, time, timestamp, codeDigits, addChecksum, truncationOffset, hmacAlgorithm } = parameters;
if (!secret)

@@ -20,5 +20,6 @@ throw new Error('no secret value');

addChecksum,
truncationOffset
truncationOffset,
hmacAlgorithm
});
}
exports.default = default_1;
{
"name": "node-otp",
"description": "Node.js One-Time Password",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -22,5 +22,9 @@ "main": "./lib/index.js",

},
"jest": {
"coverageDirectory": "./coverage/",
"collectCoverage": true
},
"devDependencies": {
"@types/node": "^8.0.53",
"jest": "^20.0.4",
"jest": "^21.2.1",
"ts-node": "^3.3.0",

@@ -27,0 +31,0 @@ "tslint": "^5.8.0",

# Node OTP
[![Travis](https://img.shields.io/travis/adnsio/node-otp/master.svg?style=flat-square)](https://travis-ci.org/adnsio/node-otp)
[![NPMV](https://img.shields.io/npm/v/node-otp.svg?style=flat-square)](https://npmjs.org/package/node-otp)
[![Travis](https://img.shields.io/travis/adnsio/node-otp.svg?style=flat-square)](https://travis-ci.org/adnsio/node-otp)
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)
Node.js One-Time Password library

@@ -7,0 +9,0 @@

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