Skip to content

Instantly share code, notes, and snippets.

@tiagorangel1
Last active November 24, 2024 08:41
Show Gist options
  • Save tiagorangel1/8db4ee6b9ef07624a66719861455332a to your computer and use it in GitHub Desktop.
Save tiagorangel1/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());
}
@tiagorangel1
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