1
0

feat: 🎸 update decodePayload

This commit is contained in:
kira924age
2023-12-21 20:53:36 +09:00
committed by Toby
parent 4be64469d3
commit 1f511549f5

View File

@@ -198,7 +198,12 @@ async function importKey(key: string | JsonWebKey, algorithm: SubtleCryptoImport
function decodePayload<T = any>(raw: string): T | undefined { function decodePayload<T = any>(raw: string): T | undefined {
try { try {
return JSON.parse(atob(raw)) const binaryString = atob(raw)
const encodedString = encodeURIComponent(binaryString).replace(/%([0-9A-F]{2})/g, (match, p1) => {
return String.fromCharCode('0x' + p1);
});
return JSON.parse(decodeURIComponent(encodedString));
} catch { } catch {
return return
} }