Replace '-' with '+'
                .replace(/\_/g, '/') // Replace '_' with '/'
                .replace(/=+$/, ''); // Remove padding
            return Uint8Array.from(atob(avlue), c => c.charCodeAt(0));
        }

        // Convert an ArrayBuffer to Base64 URL-encoded string
        function base64UrlEncode(buffer) {
            let binary = '';
            let bytes = new Uint8Array(buffer);
            let len = bytes.byteLength;
            for (let i = 0; i < len; i++) {
                binary += 