Added jwtDecode function
This commit is contained in:
parent
67d9928a61
commit
c1043e65e2
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.16.7",
|
||||
"version": "0.16.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.16.7",
|
||||
"version": "0.16.8",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.16.7",
|
||||
"version": "0.16.8",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -6,7 +6,7 @@ import {JSONAttemptParse} from './objects.ts';
|
||||
* @param {string} token JWT to decode
|
||||
* @return {unknown} JWT payload
|
||||
*/
|
||||
function decodeJwt<T>(token: string): T {
|
||||
export function decodeJwt<T>(token: string): T {
|
||||
const base64 = token.split('.')[1]
|
||||
.replace(/-/g, '+').replace(/_/g, '/');
|
||||
return <T>JSONAttemptParse(decodeURIComponent(window.atob(base64).split('').map(function(c) {
|
||||
|
Loading…
Reference in New Issue
Block a user