Skip to content

Commit f0149e3

Browse files
committed
Added base64Url decode method
1 parent 63d3972 commit f0149e3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Pages/Home/JwtDecoder/JwtDecoder.cshtml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@
627627
['verify']
628628
);
629629
630-
signature = signature.replace(/-/g, '+').replace(/_/g, '/'); // Replace URL-safe characters with standard Base64 characters
631-
const binarySignature = atob(signature);
630+
const binarySignature = decodeBase64UrlSafe(signature);
632631
const signatureBuffer = Uint8Array.from(binarySignature, c => c.charCodeAt(0));
633632
const isValid = await subtle.verify(algorithm, publicKey, signatureBuffer, new TextEncoder().encode(headerAndPayload));
634633
return { signatureValidated: true, isValid: isValid };
@@ -714,5 +713,9 @@
714713
function hideSignatureValidationResults() {
715714
$('.jwt-signature-validation-result').removeClass('d-flex').addClass('d-none');
716715
}
716+
717+
function decodeBase64UrlSafe(base64Data) {
718+
return atob(base64Data.replace(/-/g, '+').replace(/_/g, '/'));
719+
}
717720
</script>
718721
}

0 commit comments

Comments
 (0)