@levminer/speakeasy
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -8,3 +8,3 @@ module.exports = { | ||
}, | ||
extends: ["standard", "prettier", "plugin:node/recommended"], | ||
extends: ["standard", "eslint:recommended", "plugin:node/recommended", "plugin:promise/recommended", "plugin:prettier/recommended"], | ||
plugins: ["prettier"], | ||
@@ -26,6 +26,4 @@ ignorePatterns: ["/node_modules/*"], | ||
"prefer-template": ["error"], | ||
"node/no-unpublished-require": ["off"], | ||
"no-unused-vars": ["off"], | ||
"no-undef": ["off"], | ||
}, | ||
} |
// Type definitions for speakeasy 2.0 | ||
// Project: http://github.com/speakeasyjs/speakeasy | ||
// Project: https://github.com/speakeasyjs/speakeasy | ||
// Definitions by: Lucas Woo <https://github.com/legendecas>, Alexander Batukhtin <https://github.com/mrOlorin>, Aayush Kapoor <https://github.com/xeoneux> | ||
@@ -15,7 +15,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
*/ | ||
encoding?: Encoding | ||
encoding?: Encoding | undefined | ||
/** | ||
* Algorithm, defaults to sha1 | ||
*/ | ||
algorithm?: Algorithm | ||
algorithm?: Algorithm | undefined | ||
} | ||
@@ -41,3 +41,3 @@ | ||
*/ | ||
qr_code_ascii?: string | ||
qr_code_ascii?: string | undefined | ||
/** | ||
@@ -48,3 +48,3 @@ * URL for the QR code for the hex secret. | ||
*/ | ||
qr_code_hex?: string | ||
qr_code_hex?: string | undefined | ||
/** | ||
@@ -55,3 +55,3 @@ * URL for the QR code for the base32 secret. | ||
*/ | ||
qr_code_base32?: string | ||
qr_code_base32?: string | undefined | ||
/** | ||
@@ -67,3 +67,3 @@ * URL for the Google Authenticator otpauth | ||
*/ | ||
otpauth_url?: string | ||
otpauth_url?: string | undefined | ||
} | ||
@@ -83,3 +83,3 @@ export interface GeneratedSecretWithOtpAuthUrl extends GeneratedSecret { | ||
*/ | ||
key?: string | ||
key?: string | undefined | ||
} | ||
@@ -91,11 +91,11 @@ | ||
*/ | ||
length?: number | ||
length?: number | undefined | ||
/** | ||
* Whether to include symbols, defaults to false | ||
*/ | ||
symbols?: boolean | ||
symbols?: boolean | undefined | ||
/** | ||
* The name to use with Google Authenticator, deaults to 'SecretKey' | ||
*/ | ||
name?: string | ||
name?: string | undefined | ||
/** | ||
@@ -105,3 +105,3 @@ * Whether to output a Google Authenticator-compatible otpauth:// URL | ||
*/ | ||
otpauth_url?: boolean | ||
otpauth_url?: boolean | undefined | ||
/** | ||
@@ -111,3 +111,3 @@ * The provider or service with which the | ||
*/ | ||
issuer?: string | ||
issuer?: string | undefined | ||
/** | ||
@@ -119,3 +119,3 @@ * Output QR code URLs for the token. | ||
*/ | ||
qr_codes?: boolean | ||
qr_codes?: boolean | undefined | ||
/** | ||
@@ -127,3 +127,3 @@ * Output a Google Authenticator otpauth:// QR code URL. | ||
*/ | ||
google_auth_qr?: boolean | ||
google_auth_qr?: boolean | undefined | ||
} | ||
@@ -142,11 +142,11 @@ export interface GenerateSecretWithOtpAuthUrlOptions extends GenerateSecretOptions { | ||
*/ | ||
length?: number | ||
length?: number | undefined | ||
/** | ||
* The number of digits for the one-time passcode, defaults to 6 | ||
*/ | ||
digits?: number | ||
digits?: number | undefined | ||
/** | ||
* The digest, automatically generated by default | ||
*/ | ||
digest?: Buffer | ||
digest?: Buffer | undefined | ||
} | ||
@@ -171,3 +171,3 @@ | ||
*/ | ||
digits?: number | ||
digits?: number | undefined | ||
/** | ||
@@ -180,3 +180,3 @@ * The allowable margin for the counter. | ||
*/ | ||
window?: number | ||
window?: number | undefined | ||
} | ||
@@ -189,7 +189,7 @@ | ||
*/ | ||
time?: number | ||
time?: number | undefined | ||
/** | ||
* Time step in seconds, defaults to 30 | ||
*/ | ||
step?: number | ||
step?: number | undefined | ||
/** | ||
@@ -199,19 +199,19 @@ * Initial time since the UNIX epoch from which to calculate the counter value, | ||
*/ | ||
epoch?: number | ||
epoch?: number | undefined | ||
/** | ||
* @deprecated use epoch | ||
*/ | ||
initial_time?: number | ||
initial_time?: number | undefined | ||
/** | ||
* The number of digits for the one-time passcode, defaults to 6 | ||
*/ | ||
digits?: number | ||
digits?: number | undefined | ||
/** | ||
* @deprecated use digits | ||
*/ | ||
length?: number | ||
length?: number | undefined | ||
/** | ||
* The digest, automatically generated by default | ||
*/ | ||
digest?: Buffer | ||
digest?: Buffer | undefined | ||
/** | ||
@@ -224,7 +224,7 @@ * Shared secret key | ||
*/ | ||
key?: string | ||
key?: string | undefined | ||
/** | ||
* The counter value, calculated from time by default | ||
*/ | ||
counter?: number | ||
counter?: number | undefined | ||
} | ||
@@ -245,7 +245,7 @@ | ||
*/ | ||
time?: number | ||
time?: number | undefined | ||
/** | ||
* Time step in seconds, defaults to 30 | ||
*/ | ||
step?: number | ||
step?: number | undefined | ||
/** | ||
@@ -255,7 +255,7 @@ * Initial time since the UNIX epoch from which to calculate the counter value, | ||
*/ | ||
epoch?: number | ||
epoch?: number | undefined | ||
/** | ||
* The number of digits for the one-time passcode, defaults to 6 | ||
*/ | ||
digits?: number | ||
digits?: number | undefined | ||
/** | ||
@@ -268,7 +268,7 @@ * The allowable margin for the counter. | ||
*/ | ||
window?: number | ||
window?: number | undefined | ||
/** | ||
* The counter value, calculated from time by default | ||
*/ | ||
counter?: number | ||
counter?: number | undefined | ||
} | ||
@@ -289,11 +289,11 @@ | ||
*/ | ||
type?: "htop" | "totp" | ||
type?: "htop" | "totp" | undefined | ||
/** | ||
* The initial counter value, required for HOTP. | ||
*/ | ||
counter?: number | ||
counter?: number | undefined | ||
/** | ||
* The provider or service with which the secret key is associated. | ||
*/ | ||
issuer?: string | ||
issuer?: string | undefined | ||
/** | ||
@@ -303,3 +303,3 @@ * The number of digits for the one-time passcode. Currently ignored | ||
*/ | ||
digits?: number | ||
digits?: number | undefined | ||
/** | ||
@@ -309,3 +309,3 @@ * The length of time for which a TOTP code will be valid, in seconds. | ||
*/ | ||
period?: number | ||
period?: number | undefined | ||
} | ||
@@ -312,0 +312,0 @@ |
20
main.js
@@ -165,3 +165,3 @@ const base32 = require("base32.js") | ||
if (token.length !== digits) { | ||
return | ||
throw new Error("@levminer/speakeasy - hotpVerifyDelta - Wrong toke length") | ||
} | ||
@@ -174,10 +174,6 @@ | ||
if (isNaN(token)) { | ||
return | ||
throw new Error("@levminer/speakeasy - hotpVerifyDelta - Token is not a number") | ||
} | ||
// loop from C to C + W inclusive | ||
// this is a temporary fix becaouse wrong codes return a value too | ||
// FIX THIS LATER | ||
// eslint-disable-next-line no-unreachable-loop | ||
for (i = counter; i <= counter + window; ++i) { | ||
@@ -189,5 +185,7 @@ options.counter = i | ||
return { delta: i - counter } | ||
} else { | ||
return { delta: i - counter } | ||
} | ||
if (counter + window === i) { | ||
return { delta: NaN } | ||
} | ||
} | ||
@@ -494,3 +492,3 @@ | ||
label: name, | ||
issuer: issuer, | ||
issuer, | ||
}) | ||
@@ -619,3 +617,3 @@ } | ||
// build query while validating | ||
const query = { secret: secret } | ||
const query = { secret } | ||
if (issuer) { | ||
@@ -670,4 +668,4 @@ query.issuer = issuer | ||
pathname: label, | ||
query: query, | ||
query, | ||
}) | ||
} |
{ | ||
"name": "@levminer/speakeasy", | ||
"description": "Two-factor authentication for Node.js. Generate One-time passcode generator (HOTP/TOTP) with support for Google Authenticator.", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"homepage": "http://github.com/Levminer/speakeasy", | ||
@@ -28,11 +28,9 @@ "bugs": "https://github.com/Levminer/speakeasy/issues", | ||
"devDependencies": { | ||
"eslint": "^7.15.0", | ||
"eslint-config-node": "^4.1.0", | ||
"eslint-config-prettier": "^7.0.0", | ||
"eslint-config-promise": "^2.0.2", | ||
"eslint-config-standard": "^16.0.2", | ||
"eslint": "^8.11.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-config-standard": "^17.0.0-1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.2.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"prettier": "^2.2.1" | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"prettier": "^2.6.0" | ||
}, | ||
@@ -39,0 +37,0 @@ "scripts": { |
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
95043
7
1058