diff options
Diffstat (limited to 'web/assets/js')
| -rw-r--r-- | web/assets/js/model/setting.js | 3 | ||||
| -rw-r--r-- | web/assets/js/util/index.js | 27 |
2 files changed, 29 insertions, 1 deletions
diff --git a/web/assets/js/model/setting.js b/web/assets/js/model/setting.js index 6c8abe0d..89ea171f 100644 --- a/web/assets/js/model/setting.js +++ b/web/assets/js/model/setting.js @@ -23,8 +23,9 @@ class AllSetting { this.tgBotLoginNotify = true; this.tgCpu = 80; this.tgLang = "en-US"; + this.twoFactorEnable = false; + this.twoFactorToken = ""; this.xrayTemplateConfig = ""; - this.secretEnable = false; this.subEnable = false; this.subTitle = ""; this.subListen = ""; diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index a13006d4..0d869af6 100644 --- a/web/assets/js/util/index.js +++ b/web/assets/js/util/index.js @@ -145,6 +145,33 @@ class RandomUtil { return Base64.alternativeEncode(String.fromCharCode(...array)); } + + static randomBase32String(length = 16) { + const array = new Uint8Array(length); + + window.crypto.getRandomValues(array); + + const base32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; + let result = ''; + let bits = 0; + let buffer = 0; + + for (let i = 0; i < array.length; i++) { + buffer = (buffer << 8) | array[i]; + bits += 8; + + while (bits >= 5) { + bits -= 5; + result += base32Chars[(buffer >>> bits) & 0x1F]; + } + } + + if (bits > 0) { + result += base32Chars[(buffer << (5 - bits)) & 0x1F]; + } + + return result; + } } class ObjectUtil { |
