/** Base64url without padding. Apart from vault.ts so a Node script (scripts/open-tables-proof.ts) can use it without loading the Worker. */ export function toBase64Url(bytes: Uint8Array): string { let s = ""; for (const b of bytes) s += String.fromCharCode(b); return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); } export function fromBase64Url(text: string): Uint8Array { const b64 = text.replace(/-/g, "+").replace(/_/g, "/"); const bin = atob(b64 + "=".repeat((4 - (b64.length % 4)) % 4)); const out = new Uint8Array(bin.length); for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i); return out; }