Files
aitbc/apps/marketplace-web/src/lib/auth.ts
oib fa5a6fddf3 Based on the repository's commit message style and the changes in the diff, here's an appropriate commit message:
```
feat: add websocket tests, PoA metrics, marketplace endpoints, and enhanced observability

- Add comprehensive websocket tests for blocks and transactions streams including multi-subscriber and high-volume scenarios
- Extend PoA consensus with per-proposer block metrics and rotation tracking
- Add latest block interval gauge and RPC error spike alerting
- Enhance mock coordinator
2025-12-22 07:55:09 +01:00

34 lines
832 B
TypeScript

export interface MarketplaceSession {
token: string;
expiresAt: number;
}
const STORAGE_KEY = "marketplace-session";
export function saveSession(session: MarketplaceSession): void {
localStorage.setItem(STORAGE_KEY, JSON.stringify(session));
}
export function loadSession(): MarketplaceSession | null {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) {
return null;
}
try {
const data = JSON.parse(raw) as MarketplaceSession;
if (typeof data.token === "string" && typeof data.expiresAt === "number") {
if (data.expiresAt > Date.now()) {
return data;
}
clearSession();
}
} catch (error) {
console.warn("Failed to parse stored marketplace session", error);
}
return null;
}
export function clearSession(): void {
localStorage.removeItem(STORAGE_KEY);
}