Nonopt
This commit is contained in:
parent
14655e5633
commit
26436f116f
|
@ -176,10 +176,11 @@ 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 ?? Code.defaultAlgo,
|
algorithm: codeInfo.algorithm ?? Code.defaultAlgo,
|
||||||
period: codeInfo.period ?? Code.defaultPeriod,
|
period: codeInfo.period,
|
||||||
digits: codeInfo.digits,
|
digits: codeInfo.digits,
|
||||||
});
|
});
|
||||||
setOTP(totp.generate());
|
setOTP(totp.generate());
|
||||||
|
@ -274,7 +275,7 @@ const OTPDisplay: React.FC<OTPDisplayProps> = ({ code, otp, nextOTP }) => {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TimerProgress period={code.period ?? Code.defaultPeriod} />
|
<TimerProgress period={code.period} />
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
padding: "12px 20px 0px 20px",
|
padding: "12px 20px 0px 20px",
|
||||||
|
|
|
@ -12,7 +12,6 @@ type AlgorithmType =
|
||||||
|
|
||||||
export class Code {
|
export class Code {
|
||||||
static readonly defaultAlgo = "sha1";
|
static readonly defaultAlgo = "sha1";
|
||||||
static readonly defaultPeriod = 30;
|
|
||||||
|
|
||||||
// id for the corresponding auth entity
|
// id for the corresponding auth entity
|
||||||
id?: String;
|
id?: String;
|
||||||
|
@ -83,7 +82,7 @@ export const codeFromRawData = (id: string, rawData: string): Code => {
|
||||||
_getAccount(uriPath),
|
_getAccount(uriPath),
|
||||||
_getIssuer(uriPath, uriParams),
|
_getIssuer(uriPath, uriParams),
|
||||||
_getDigits(uriParams) || 6,
|
_getDigits(uriParams) || 6,
|
||||||
_getPeriod(uriParams),
|
_getPeriod(uriParams) || 30,
|
||||||
getSanitizedSecret(uriParams),
|
getSanitizedSecret(uriParams),
|
||||||
_getAlgorithm(uriParams),
|
_getAlgorithm(uriParams),
|
||||||
_getType(uriPath),
|
_getType(uriPath),
|
||||||
|
@ -138,11 +137,11 @@ const _getDigits = (uriParams): number | undefined => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const _getPeriod = (uriParams): number => {
|
const _getPeriod = (uriParams): number | undefined => {
|
||||||
try {
|
try {
|
||||||
return parseInt(uriParams["period"], 10) || Code.defaultPeriod;
|
return parseInt(uriParams["period"], 10);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Code.defaultPeriod;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue