feat(panel): implement email otp and passkey login interface
This commit is contained in:
13 files changed
+520
-116
No files matched your search
@@ -5,3 +5,31 @@ import { twMerge } from "tailwind-merge";
|
||||
export function cn(...inputs: ClassValue[]): string {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
export function base64urlToBytes(str: string): ArrayBuffer {
|
||||
let base64 = str.replace(/-/g, "+").replace(/_/g, "/");
|
||||
const pad = base64.length % 4;
|
||||
if (pad) {
|
||||
base64 += "=".repeat(4 - pad);
|
||||
}
|
||||
const binary = atob(base64);
|
||||
const bytes = new Uint8Array(binary.length);
|
||||
for (let i = 0; i < binary.length; i++) {
|
||||
bytes[i] = binary.charCodeAt(i);
|
||||
}
|
||||
return bytes.buffer;
|
||||
}
|
||||
|
||||
export function bytesToBase64url(bytes: ArrayBuffer): string {
|
||||
let binary = "";
|
||||
const uint8 = new Uint8Array(bytes);
|
||||
const len = uint8.byteLength;
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(uint8[i]);
|
||||
}
|
||||
const base64 = btoa(binary);
|
||||
return base64
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/, "");
|
||||
}
|
||||
Reference in new issue
Block a user