Ir al contenido principal
kitlocal.dev

Visor de Git diff

Ejecución local

Procesado al 100 % en tu navegador. Las entradas y salidas nunca salen de tu dispositivo.

Visor de diff de Git con resaltado de sintaxis y comparación en paralelo.

Contexto

Código original

Código modificado

Diferencias línea por línea (Diff)

+8 añadidas-4 eliminadas
1import { readCache, writeCache } from './cache';1import { deleteCache, readCache, writeCache } from './cache';
22
3export interface UserSession {3export interface UserSession {
4 id: string;4 id: string;
5 role: 'viewer' | 'editor';5 role: 'viewer' | 'editor' | 'admin';
6 expiresAt: number;6 expiresAt: number;
7 issuedAt: number;
7}8}
89
9export async function refreshSession(token: string): Promise<UserSession | null> {10export async function refreshSession(token: string): Promise<UserSession | null> {
10 if (!token) {11 const trimmed = token.trim();
12 if (!trimmed) {
11 return null;13 return null;
12 }14 }
13 const cached = await readCache(token);15 const cached = await readCache(trimmed);
14 if (cached && cached.expiresAt > Date.now()) {16 if (cached && cached.expiresAt > Date.now()) {
17 await writeCache(trimmed, cached);
15 return cached;18 return cached;
16 }19 }
20 await deleteCache(trimmed);
17 return null;21 return null;
18}22}