Added pull request from GitHub https://github.com/Lisoveliy/totpfit/pull/1, fix of settings app #11
@ -54,6 +54,6 @@ export function getTOTP(
|
|||||||
timeOffset = 0,
|
timeOffset = 0,
|
||||||
hashType = "SHA-1",
|
hashType = "SHA-1",
|
||||||
) {
|
) {
|
||||||
const unixTime = Math.round((time / 1000 + timeOffset) / fetchTime);
|
const unixTime = Math.round((time / 1000n + timeOffset) / fetchTime);
|
||||||
return getHOTP(BigInt(unixTime), secret, digits);
|
return getHOTP(BigInt(unixTime), secret, digits, hashType);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ export class TOTP {
|
|||||||
*/
|
*/
|
||||||
getOTP(time = Date.now()) {
|
getOTP(time = Date.now()) {
|
||||||
const unixTime = (time / 1000 + this.timeOffset) / this.fetchTime;
|
const unixTime = (time / 1000 + this.timeOffset) / this.fetchTime;
|
||||||
const otp = getHOTP(Math.floor(unixTime), this.secret, this.digits);
|
const otp = getHOTP(Math.floor(unixTime), this.secret, this.digits, this.hashType);
|
||||||
const expireTime =
|
const expireTime =
|
||||||
time +
|
time +
|
||||||
(this.fetchTime -
|
(this.fetchTime -
|
||||||
((time / 1000 + this.timeOffset) % this.fetchTime)) *
|
((time / 1000 + this.timeOffset) % this.fetchTime)) *
|
||||||
1000;
|
1000;
|
||||||
const createdTime =
|
const createdTime =
|
||||||
time - ((time / 1000 + this.timeOffset) % this.fetchTime) * 1000;
|
time - ((time / 1000 + this.timeOffset) % this.fetchTime) * 1000;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user