Skip to content

Instantly share code, notes, and snippets.

@tiagozip
Last active May 17, 2025 10:33
Show Gist options
  • Select an option

  • Save tiagozip/8db4ee6b9ef07624a66719861455332a to your computer and use it in GitHub Desktop.

Select an option

Save tiagozip/8db4ee6b9ef07624a66719861455332a to your computer and use it in GitHub Desktop.
JWT decoder used for Authflow
// 💡 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());
}
@tiagozip
Copy link
Author

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