feat: changed TOTP and base32 library to self-writed special for quick-js, fixed BigInt incompatibility

This commit is contained in:
Савелий Савенок
2024-11-13 02:30:53 +03:00
parent ab13957cb0
commit f16d7374f4
14 changed files with 147 additions and 328 deletions

View File

@@ -33,8 +33,9 @@ Page({
const buttonHeight = height / 4;
const margin = 10;
let totpHeight = margin;
for(let i = 0; i < buffer.length; i++){
console.log(buffer[i])
createWidget(widget.FILL_RECT, {
x: width / 2 - buttonWidth / 2,
y: totpHeight,
@@ -53,7 +54,7 @@ Page({
align_h: align.CENTER_H,
align_v: align.CENTER_V,
text_style: text_style.NONE,
text: buffer[i].name
text: (buffer[i].expireTime - Date.now()) / 1000
})
createWidget(widget.TEXT, {
x: 0,
@@ -65,7 +66,7 @@ Page({
align_h: align.CENTER_H,
align_v: align.CENTER_V,
text_style: text_style.NONE,
text: buffer[i].data
text: buffer[i].otp
})
totpHeight += margin + buttonHeight;

View File

@@ -1,4 +1,4 @@
import { TOTP } from "../../lib/totp.js/lib/totp";
import { TOTP } from "../../lib/totp-quickjs";
export class TOTPBuffer{
constructor(){
@@ -6,15 +6,6 @@ export class TOTPBuffer{
}
getTOTPs(){
return [new TOTPData("Contabo-Customer-Control-Panel-11755808: my.contabo.com", new TOTP(TOTP.encode('UU5WIIWKDNAHUNNL')).genOTP()),
new TOTPData("OTPData", new TOTP(TOTP.encode('LCHJZO23LT3Z2QYNYAYAJXH5HFDZ5YI2')).genOTP()),
new TOTPData("test", new TOTP(TOTP.encode('GAXHMZDEGJVG64LP')).genOTP())]
}
}
export class TOTPData{
constructor(name, data){
this.name = name;
this.data = data;
return [new TOTP('JBSWY3DPEHPK3PXP').getOTP()]
}
}