Last active
November 24, 2024 08:41
-
-
Save tiagorangel1/8db4ee6b9ef07624a66719861455332a to your computer and use it in GitHub Desktop.
JWT decoder used for Authflow
This file contains hidden or 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
// 💡 Tip: need to decode with node.js? Use the @authflow-js/verify npm module | |
function decryptJWT(e) { | |
return JSON.parse((typeof Buffer !== "undefined" ? Buffer.from(token.split('.')[1], 'base64') : atob(token.split('.')[1])).toString()); | |
} |
Possibly the encoding algorithm used in that JWT is different than the one the function tests for, apologies!
figured it out. Buffer is not available in the browser, so I changed your implementation to figure out if it needs to use Buffer or atob.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cmdwm
Thx, checking it out!EDIT: After some simple tests it failed with "Error". Anyway, thanks for the suggestion! Valid JWT used for testing:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c