feat: release 2.7.0-rc2
This commit is contained in:
+5
-1
@@ -52,6 +52,7 @@ function isSession(value: unknown): value is KuberSession {
|
||||
return (
|
||||
typeof session.token === "string" &&
|
||||
typeof session.expiresAt === "string" &&
|
||||
Number.isFinite(Date.parse(session.expiresAt)) &&
|
||||
Boolean(session.user) &&
|
||||
typeof session.user?.username === "string" &&
|
||||
Array.isArray(session.user.roles) &&
|
||||
@@ -64,7 +65,10 @@ async function readSessionFile(
|
||||
): Promise<KuberSession | undefined> {
|
||||
try {
|
||||
const value: unknown = JSON.parse(await readFile(path, "utf8"));
|
||||
if (!isSession(value)) return;
|
||||
if (!isSession(value)) {
|
||||
await rm(path, { force: true });
|
||||
return;
|
||||
}
|
||||
if (Date.parse(value.expiresAt) <= Date.now()) {
|
||||
await rm(path, { force: true });
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user