refactor: delete base64js

instead of base64 library you can use built-in JS functions `btoa()` and `atob()`
This commit is contained in:
Shishkevich D.
2025-03-07 07:11:03 +00:00
parent 2d8cca3a2e
commit 7483fb2ec5
5 changed files with 19 additions and 15 deletions
-11
View File
@@ -39,17 +39,6 @@ function cpuCoreFormat(cores) {
}
}
function base64(str) {
return Base64.encode(str);
}
function safeBase64(str) {
return base64(str)
.replace(/\+/g, '-')
.replace(/=/g, '')
.replace(/\//g, '_');
}
function formatSecond(second) {
if (second < 60) {
return second.toFixed(0) + 's';
+17
View File
@@ -478,4 +478,21 @@ class Wireguard {
privateKey: secretKey.length > 0 ? secretKey : this.keyToBase64(privateKey)
};
}
}
class Base64 {
static encode(content = "", safe = false) {
if (safe) {
return window.btoa(content)
.replace(/\+/g, '-')
.replace(/=/g, '')
.replace(/\//g, '_')
}
return window.btoa(content)
}
static decode(content = "") {
return window.atob(content)
}
}