auth: use unicode b64 encoding on browser

brought over unicodeB64Encode/Decode from my other filaments project.
Fixes #364.
This commit is contained in:
Harvey Tindall
2024-08-28 14:29:36 +01:00
parent 02f4ba6e8e
commit 6347495b5b
2 changed files with 15 additions and 2 deletions
+13
View File
@@ -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);
}