@accounts/two-factor
Advanced tools
Comparing version 0.32.4 to 1.0.0-alpha-20231022085748-0910b9e1
import { GeneratedSecret } from '@levminer/speakeasy'; | ||
import { User, DatabaseInterface } from '@accounts/types'; | ||
import { User, DatabaseInterfaceUser } from '@accounts/types'; | ||
import { AccountsTwoFactorOptions } from './types'; | ||
export declare class TwoFactor { | ||
export declare class TwoFactor<CustomUser extends User = User> { | ||
private options; | ||
@@ -13,3 +13,3 @@ private db; | ||
*/ | ||
setStore(store: DatabaseInterface): void; | ||
setUserStore(store: DatabaseInterfaceUser<CustomUser>): void; | ||
/** | ||
@@ -16,0 +16,0 @@ * Authenticate a user with a 2fa code |
@@ -13,6 +13,2 @@ "use strict"; | ||
class TwoFactor { | ||
constructor(options = {}) { | ||
this.serviceName = 'two-factor'; | ||
this.options = { ...defaultOptions, ...options }; | ||
} | ||
verifyTOTPCode(secret, code) { | ||
@@ -34,6 +30,10 @@ try { | ||
} | ||
constructor(options = {}) { | ||
this.serviceName = 'two-factor'; | ||
this.options = { ...defaultOptions, ...options }; | ||
} | ||
/** | ||
* Set two factor store | ||
*/ | ||
setStore(store) { | ||
setUserStore(store) { | ||
this.db = store; | ||
@@ -40,0 +40,0 @@ } |
{ | ||
"name": "@accounts/two-factor", | ||
"version": "0.32.4", | ||
"version": "1.0.0-alpha-20231022085748-0910b9e1", | ||
"license": "MIT", | ||
@@ -10,2 +10,12 @@ "main": "lib/index.js", | ||
}, | ||
"scripts": { | ||
"clean": "yarn run -T rimraf lib", | ||
"start": "yarn run -T tsc --watch", | ||
"precompile": "yarn run clean", | ||
"compile": "yarn run -T tsc", | ||
"prepublishOnly": "yarn run compile", | ||
"test": "yarn run test", | ||
"testonly": "yarn run -T jest", | ||
"coverage": "yarn run -T jest --coverage" | ||
}, | ||
"files": [ | ||
@@ -20,23 +30,6 @@ "src", | ||
"dependencies": { | ||
"@accounts/types": "^0.33.2", | ||
"@levminer/speakeasy": "1.3.3", | ||
"tslib": "2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "27.0.2", | ||
"@types/node": "16.11.7", | ||
"jest": "27.3.1", | ||
"rimraf": "3.0.2", | ||
"ts-jest": "27.0.7" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"start": "tsc --watch", | ||
"precompile": "pnpm run clean", | ||
"compile": "tsc", | ||
"test": "npm run test", | ||
"testonly": "jest --coverage", | ||
"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" | ||
} | ||
"@accounts/types": "1.0.0-alpha-20231022085748-0910b9e1", | ||
"@levminer/speakeasy": "1.4.2", | ||
"tslib": "2.6.2" | ||
} | ||
} |
import { GeneratedSecret, generateSecret, totp } from '@levminer/speakeasy'; | ||
import { User, DatabaseInterface } from '@accounts/types'; | ||
import { User, DatabaseInterfaceUser } from '@accounts/types'; | ||
import { errors } from './errors'; | ||
@@ -13,5 +13,5 @@ import { AccountsTwoFactorOptions } from './types'; | ||
export class TwoFactor { | ||
export class TwoFactor<CustomUser extends User = User> { | ||
private options: AccountsTwoFactorOptions & typeof defaultOptions; | ||
private db!: DatabaseInterface; | ||
private db!: DatabaseInterfaceUser<CustomUser>; | ||
private serviceName = 'two-factor'; | ||
@@ -41,3 +41,3 @@ | ||
*/ | ||
public setStore(store: DatabaseInterface): void { | ||
public setUserStore(store: DatabaseInterfaceUser<CustomUser>): void { | ||
this.db = store; | ||
@@ -44,0 +44,0 @@ } |
Sorry, the diff of this file is not supported yet
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
0
19048
38
+ Added@accounts/types@1.0.0-alpha-20231022085748-0910b9e1(transitive)
+ Added@levminer/speakeasy@1.4.2(transitive)
+ Addedtslib@2.6.2(transitive)
- Removed@accounts/types@0.33.2(transitive)
- Removed@levminer/speakeasy@1.3.3(transitive)
- Removedbase32.js@0.1.0(transitive)
- Removedtslib@2.3.1(transitive)
Updated@levminer/speakeasy@1.4.2
Updatedtslib@2.6.2