Document
This commit is contained in:
parent
41c87efc5a
commit
206be5c16f
2 changed files with 9 additions and 2 deletions
|
@ -176,7 +176,6 @@ const CodeDisplay: React.FC<CodeDisplay> = ({ codeInfo }) => {
|
||||||
try {
|
try {
|
||||||
const currentTime = new Date().getTime();
|
const currentTime = new Date().getTime();
|
||||||
if (codeInfo.type.toLowerCase() === "totp") {
|
if (codeInfo.type.toLowerCase() === "totp") {
|
||||||
console.log({ codeInfo });
|
|
||||||
const totp = new TOTP({
|
const totp = new TOTP({
|
||||||
secret: codeInfo.secret,
|
secret: codeInfo.secret,
|
||||||
algorithm: codeInfo.algorithm,
|
algorithm: codeInfo.algorithm,
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class Code {
|
||||||
constructor(
|
constructor(
|
||||||
account: string,
|
account: string,
|
||||||
issuer: string,
|
issuer: string,
|
||||||
digits: number | undefined,
|
digits: number,
|
||||||
period: number,
|
period: number,
|
||||||
secret: string,
|
secret: string,
|
||||||
algorithm: Algorithm,
|
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 => {
|
export const codeFromRawData = (id: string, rawData: string): Code => {
|
||||||
let santizedRawData = rawData
|
let santizedRawData = rawData
|
||||||
.replace(/\+/g, "%2B")
|
.replace(/\+/g, "%2B")
|
||||||
|
|
Loading…
Reference in a new issue