more dev work
This commit is contained in:
parent
84261c9537
commit
441056cabc
12 changed files with 59 additions and 80 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { authenticator } from "otplib";
|
||||
import { createHash } from "crypto";
|
||||
import { createHmac } from "crypto";
|
||||
import base32 from "thirty-two";
|
||||
|
||||
const submissionTimestamps = new Map<string, number[]>();
|
||||
const otpRequestTimestamps = new Map<string, number[]>();
|
||||
|
|
@ -52,9 +53,9 @@ function getUserSecret(phoneNumber: string, salt: string): string {
|
|||
"Phone number and salt are required to generate a user secret.",
|
||||
);
|
||||
}
|
||||
return createHash("sha256")
|
||||
.update(phoneNumber + salt)
|
||||
.digest("hex");
|
||||
|
||||
const digest = createHmac("sha256", salt).update(phoneNumber).digest("hex");
|
||||
return base32.encode(digest).toString().replace(/=/g, "");
|
||||
}
|
||||
|
||||
export function normalizePhone(phone: string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue