export class JWTUtils {
    static decode(token) {
        const base64Url = token.split(".")[1];
        const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
        const jsonPayload = decodeURIComponent(window
            .atob(base64)
            .split("")
            .map(function (c) {
            return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
        })
            .join(""));
        return JSON.parse(jsonPayload);
    }
    static getExpiration(token) {
        const decoded = JWTUtils.decode(token);
        return decoded.exp;
    }
    static isExpired(token) {
        const expiration = JWTUtils.getExpiration(token);
        const now = new Date().getTime() / 1000;
        return expiration < now;
    }
}
