switched to hono/jwt to save some kb

This commit is contained in:
dswbx
2024-11-25 17:54:26 +01:00
parent 16a6a3315d
commit 1c94777317
7 changed files with 49 additions and 41 deletions

View File

@@ -1,6 +1,6 @@
import { AuthApi } from "auth/api/AuthApi";
import { DataApi } from "data/api/DataApi";
import { decodeJwt } from "jose";
import { decode } from "hono/jwt";
import { MediaApi } from "media/api/MediaApi";
import { SystemApi } from "modules/SystemApi";
@@ -51,7 +51,7 @@ export class Api {
const token = localStorage.getItem(this.tokenKey);
if (token) {
this.token = token;
this.user = decodeJwt(token) as any;
this.user = decode(token).payload as any;
}
} else {
if (typeof window !== "undefined" && "__BKND__" in window) {
@@ -63,7 +63,7 @@ export class Api {
updateToken(token?: string, rebuild?: boolean) {
this.token = token;
this.user = token ? (decodeJwt(token) as any) : undefined;
this.user = token ? (decode(token).payload as any) : undefined;
if (this.tokenStorage === "localStorage") {
const key = this.tokenKey;