Fix PKCE's URL-safe Base64 encoding

This commit is contained in:
Zdeněk Biberle
2023-12-06 14:28:36 +01:00
parent e7a41e9885
commit 4474cc42a6

View File

@@ -128,8 +128,8 @@
const data = encoder.encode(verifier);
const digest = await crypto.subtle.digest('SHA-256', data);
const base64UrlEncoded = btoa(String.fromCharCode(...new Uint8Array(digest)))
.replace('+', '-')
.replace('/', '_')
.replaceAll('+', '-')
.replaceAll('/', '_')
.replace(/=+$/, '');
$('#codeChallenge').val(base64UrlEncoded);