Created
June 26, 2023 06:32
-
-
Save mikhail-angelov/479df89cc15a7609a1c780026813ca74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function encodeJWT(payload){ | |
function base64urlEncode(str) { | |
return window.btoa(unescape(encodeURIComponent(str))) | |
} | |
const segments = [ | |
base64urlEncode(JSON.stringify({ typ: 'JWT', alg: 'HS256' })), | |
base64urlEncode(JSON.stringify(payload)), | |
'fake-signature' | |
]; | |
return segments.join('.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment