Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShishkevich D. <135337715+shishkevichd@users.noreply.github.com>2025-05-08 17:20:58 +0300
committerGitHub <noreply@github.com>2025-05-08 17:20:58 +0300
commitfe3b1c9b52f584b0f045907585b206344fed55db (patch)
treeaeef0fa82a0355ee899ec3aecee23045a327a6dc /web/assets/js/util
parentd39ccf4b8f77f99d4468580085e9d89e8b5f0b1c (diff)
chore: implement 2fa auth (#2968)
* chore: implement 2fa auth from #2786 * chore: format code * chore: replace two factor token input with qr-code * chore: requesting confirmation of setting/removing two-factor authentication otpauth library was taken from cdnjs * chore: revert changes in `ClipboardManager` don't need it. * chore: removing twoFactor prop in settings page * chore: remove `twoFactorQr` object in `mounted` function
Diffstat (limited to 'web/assets/js/util')
-rw-r--r--web/assets/js/util/index.js27
1 files changed, 27 insertions, 0 deletions
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 {