Added jwtDecode function
All checks were successful
Build / Build NPM Project (push) Successful in 27s
Build / Tag Version (push) Successful in 7s

This commit is contained in:
Zakary Timson 2024-09-30 16:02:21 -04:00
parent 67d9928a61
commit c1043e65e2
3 changed files with 4 additions and 4 deletions

4
package-lock.json generated
View File

@ -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",

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.16.7",
"version": "0.16.8",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -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) {