mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: migrate notp to otpauth (#1157)
This commit is contained in:
1 parent
bbcaa61d64
commit
62cabb1034
2 files changed
+5
-8
No files matched your search
@@ -44,7 +44,7 @@
|
|||||||
"mongodb-uri": "^0.9.7",
|
"mongodb-uri": "^0.9.7",
|
||||||
"nanoid": "^5.1.11",
|
"nanoid": "^5.1.11",
|
||||||
"nodemailer": "^8.0.7",
|
"nodemailer": "^8.0.7",
|
||||||
"notp": "^2.0.3",
|
"otpauth": "^9.5.1",
|
||||||
"p-queue": "^9.2.0",
|
"p-queue": "^9.2.0",
|
||||||
"sanitize-filename": "^1.6.4",
|
"sanitize-filename": "^1.6.4",
|
||||||
"schemastery": "^3.18.0",
|
"schemastery": "^3.18.0",
|
||||||
@@ -53,7 +53,6 @@
|
|||||||
"superagent": "^10.3.0",
|
"superagent": "^10.3.0",
|
||||||
"superagent-proxy": "^3.0.0",
|
"superagent-proxy": "^3.0.0",
|
||||||
"tar": "6.2.1",
|
"tar": "6.2.1",
|
||||||
"thirty-two": "^1.0.2",
|
|
||||||
"ua-parser-js": "1.0.41"
|
"ua-parser-js": "1.0.41"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -66,7 +65,6 @@
|
|||||||
"@types/mime-types": "^3.0.1",
|
"@types/mime-types": "^3.0.1",
|
||||||
"@types/mongodb-uri": "^0.9.4",
|
"@types/mongodb-uri": "^0.9.4",
|
||||||
"@types/nodemailer": "^8.0.0",
|
"@types/nodemailer": "^8.0.0",
|
||||||
"@types/notp": "^2.0.5",
|
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/superagent": "^8.1.9",
|
"@types/superagent": "^8.1.9",
|
||||||
"@types/superagent-proxy": "^3.0.4",
|
"@types/superagent-proxy": "^3.0.4",
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import notp from 'notp';
|
import { Secret, TOTP } from 'otpauth';
|
||||||
import b32 from 'thirty-two';
|
|
||||||
|
|
||||||
export function verifyTFA(secret: string, code?: string) {
|
export function verifyTFA(secret: string, code?: string) {
|
||||||
if (!code || !code.length) return null;
|
if (!code || !code.length) return false;
|
||||||
const bin = b32.decode(secret);
|
const totp = new TOTP({ secret: Secret.fromBase32(secret), algorithm: 'SHA1', digits: 6, period: 30 });
|
||||||
return notp.totp.verify(code.replace(/\W+/g, ''), bin);
|
return totp.validate({ token: code.replace(/\W+/g, '') }) !== null;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user