1
0

Fix unicode payload signing

This commit is contained in:
Richard Lee
2024-01-08 01:30:56 +08:00
committed by Toby
parent b05345279d
commit 11afa8eb87
2 changed files with 14 additions and 1 deletions

View File

@@ -157,7 +157,10 @@ function base64UrlToArrayBuffer(b64url: string): ArrayBuffer {
}
function textToBase64Url(str: string): string {
return btoa(str).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
const encoder = new TextEncoder();
const charCodes = encoder.encode(str);
const binaryStr = String.fromCharCode(...charCodes);
return btoa(binaryStr).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
}
function pemToBinary(pem: string): ArrayBuffer {