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

@accounts/two-factor

Package Overview
Dependencies
Maintainers
3
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@accounts/two-factor - npm Package Compare versions

Comparing version 0.32.2 to 0.32.3

6

lib/two-factor.d.ts

@@ -1,2 +0,2 @@

import * as speakeasy from 'speakeasy';
import { GeneratedSecret } from '@levminer/speakeasy';
import { User, DatabaseInterface } from '@accounts/types';

@@ -20,3 +20,3 @@ import { AccountsTwoFactorOptions } from './types';

*/
getNewAuthSecret(): speakeasy.Key;
getNewAuthSecret(): GeneratedSecret;
/**

@@ -27,3 +27,3 @@ * Verify the code is correct

*/
set(userId: string, secret: speakeasy.Key, code: string): Promise<void>;
set(userId: string, secret: GeneratedSecret, code: string): Promise<void>;
/**

@@ -30,0 +30,0 @@ * Remove two factor for a user

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TwoFactor = void 0;
const tslib_1 = require("tslib");
const speakeasy = tslib_1.__importStar(require("speakeasy"));
const speakeasy_1 = require("@levminer/speakeasy");
const errors_1 = require("./errors");

@@ -31,3 +30,3 @@ const utils_1 = require("./utils");

}
const twoFactorService = utils_1.getUserTwoFactorService(user);
const twoFactorService = (0, utils_1.getUserTwoFactorService)(user);
// If user does not have 2fa set return error

@@ -37,3 +36,3 @@ if (!twoFactorService) {

}
if (!speakeasy.totp.verify({
if (!speakeasy_1.totp.verify({
secret: twoFactorService.secret.base32,

@@ -51,3 +50,3 @@ encoding: 'base32',

getNewAuthSecret() {
return speakeasy.generateSecret({
return (0, speakeasy_1.generateSecret)({
length: this.options.secretLength,

@@ -70,3 +69,3 @@ name: this.options.appName,

}
let twoFactorService = utils_1.getUserTwoFactorService(user);
let twoFactorService = (0, utils_1.getUserTwoFactorService)(user);
// If user already have 2fa return error

@@ -76,3 +75,3 @@ if (twoFactorService) {

}
if (speakeasy.totp.verify({
if (speakeasy_1.totp.verify({
secret: secret.base32,

@@ -103,3 +102,3 @@ encoding: 'base32',

}
const twoFactorService = utils_1.getUserTwoFactorService(user);
const twoFactorService = (0, utils_1.getUserTwoFactorService)(user);
// If user does not have 2fa set return error

@@ -109,3 +108,3 @@ if (!twoFactorService) {

}
if (speakeasy.totp.verify({
if (speakeasy_1.totp.verify({
secret: twoFactorService.secret.base32,

@@ -116,3 +115,3 @@ encoding: 'base32',

})) {
this.db.unsetService(userId, this.serviceName);
await this.db.unsetService(userId, this.serviceName);
}

@@ -119,0 +118,0 @@ else {

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

import * as speakeasy from 'speakeasy';
import { GeneratedSecret } from '@levminer/speakeasy';
export interface TwoFactorService {
secret: speakeasy.Key;
secret: GeneratedSecret;
}
{
"name": "@accounts/two-factor",
"version": "0.32.2",
"version": "0.32.3",
"license": "MIT",

@@ -19,13 +19,12 @@ "main": "lib/index.js",

"dependencies": {
"@accounts/types": "^0.33.1",
"@types/speakeasy": "2.0.2",
"speakeasy": "^2.0.0",
"tslib": "2.3.0"
"@accounts/types": "^0.33.2",
"@levminer/speakeasy": "1.3.1",
"tslib": "2.3.1"
},
"devDependencies": {
"@types/jest": "26.0.24",
"@types/node": "16.4.13",
"jest": "27.0.6",
"@types/jest": "27.0.2",
"@types/node": "16.11.7",
"jest": "27.3.1",
"rimraf": "3.0.2",
"ts-jest": "27.0.4"
"ts-jest": "27.0.7"
},

@@ -40,3 +39,4 @@ "scripts": {

"coverage": "jest --coverage"
}
},
"readme": "# @accounts/two-factor\n\n[![npm](https://img.shields.io/npm/v/@accounts/two-factor.svg)](https://www.npmjs.com/package/@accounts/two-factor)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n"
}

@@ -1,2 +0,2 @@

import * as speakeasy from 'speakeasy';
import { GeneratedSecret, generateSecret, totp } from '@levminer/speakeasy';
import { User, DatabaseInterface } from '@accounts/types';

@@ -43,3 +43,3 @@ import { errors } from './errors';

if (
!speakeasy.totp.verify({
!totp.verify({
secret: twoFactorService.secret.base32,

@@ -58,4 +58,4 @@ encoding: 'base32',

*/
public getNewAuthSecret(): speakeasy.Key {
return speakeasy.generateSecret({
public getNewAuthSecret(): GeneratedSecret {
return generateSecret({
length: this.options.secretLength,

@@ -71,3 +71,3 @@ name: this.options.appName,

*/
public async set(userId: string, secret: speakeasy.Key, code: string): Promise<void> {
public async set(userId: string, secret: GeneratedSecret, code: string): Promise<void> {
if (!code) {

@@ -88,3 +88,3 @@ throw new Error(this.options.errors.codeRequired);

if (
speakeasy.totp.verify({
totp.verify({
secret: secret.base32,

@@ -123,3 +123,3 @@ encoding: 'base32',

if (
speakeasy.totp.verify({
totp.verify({
secret: twoFactorService.secret.base32,

@@ -131,3 +131,3 @@ encoding: 'base32',

) {
this.db.unsetService(userId, this.serviceName);
await this.db.unsetService(userId, this.serviceName);
} else {

@@ -134,0 +134,0 @@ throw new Error(this.options.errors.codeDidNotMatch);

@@ -1,5 +0,5 @@

import * as speakeasy from 'speakeasy';
import { GeneratedSecret } from '@levminer/speakeasy';
export interface TwoFactorService {
secret: speakeasy.Key;
secret: GeneratedSecret;
}

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