diff --git a/ts/modules/common.ts b/ts/modules/common.ts index 208be19..d87498a 100644 --- a/ts/modules/common.ts +++ b/ts/modules/common.ts @@ -291,3 +291,16 @@ export function bindManualDropdowns() { }; } } + +export function unicodeB64Decode(s: string): string { + const decoded = atob(s); + const byteArray = Uint8Array.from(decoded, (m) => m.codePointAt(0)); + const toUnicode = new TextDecoder().decode(byteArray); + return toUnicode; +} + +export function unicodeB64Encode(s: string): string { + const encoded = new TextEncoder().encode(s); + const bin = String.fromCodePoint(...encoded); + return btoa(bin); +} diff --git a/ts/modules/login.ts b/ts/modules/login.ts index ea74103..71cd590 100644 --- a/ts/modules/login.ts +++ b/ts/modules/login.ts @@ -1,5 +1,5 @@ import { Modal } from "../modules/modal.js"; -import { toggleLoader, _post } from "../modules/common.js"; +import { toggleLoader, _post, unicodeB64Encode } from "../modules/common.js"; export class Login { loggedIn: boolean = false; @@ -68,7 +68,7 @@ export class Login { const refresh = (username == "" && password == ""); req.open("GET", this._url + (refresh ? "token/refresh" : "token/login"), true); if (!refresh) { - req.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password)); + req.setRequestHeader("Authorization", "Basic " + unicodeB64Encode(username + ":" + password)); } req.onreadystatechange = ((req: XMLHttpRequest, _: Event): any => { if (req.readyState == 4) {