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
This commit is contained in:
33
apps/marketplace-web/src/lib/auth.ts
Normal file
33
apps/marketplace-web/src/lib/auth.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user