export const encodeBase64Url = (bytes: Uint8Array): string => { let binary = ""; for (let i = 0; i < bytes.length; i += 1) { binary += String.fromCharCode(bytes[i]); } return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); }; export const sha256 = async (input: string): Promise => { const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(input)); return encodeBase64Url(new Uint8Array(digest)); };