feat: 🎸 update decodePayload
This commit is contained in:
@@ -198,7 +198,12 @@ async function importKey(key: string | JsonWebKey, algorithm: SubtleCryptoImport
|
||||
|
||||
function decodePayload<T = any>(raw: string): T | undefined {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user