This commit is contained in:
Manav Rathi 2024-05-23 13:19:05 +05:30
parent 41c87efc5a
commit 206be5c16f
No known key found for this signature in database
2 changed files with 9 additions and 2 deletions

View file

@ -176,7 +176,6 @@ const CodeDisplay: React.FC<CodeDisplay> = ({ codeInfo }) => {
try {
const currentTime = new Date().getTime();
if (codeInfo.type.toLowerCase() === "totp") {
console.log({ codeInfo });
const totp = new TOTP({
secret: codeInfo.secret,
algorithm: codeInfo.algorithm,

View file

@ -19,7 +19,7 @@ export class Code {
constructor(
account: string,
issuer: string,
digits: number | undefined,
digits: number,
period: number,
secret: string,
algorithm: Algorithm,
@ -39,6 +39,14 @@ export class Code {
}
}
/**
* Convert a "raw" OTP secret URL into its parse representation, a {@link Code}.
*
* An example {@link rawData}:
*
* otpauth://totp/account:user@example.org?algorithm=SHA1&digits=6&issuer=issuer&period=30&secret=ALPHANUM
*
*/
export const codeFromRawData = (id: string, rawData: string): Code => {
let santizedRawData = rawData
.replace(/\+/g, "%2B")