Files
penx/apps/web/lib/local-session.ts
0xzio 3edfe1aebf refactor: use monorepo
fix: fix build

chore: update README

feat: init extension

fix: fix web build
2025-04-19 01:48:59 +08:00

35 lines
657 B
TypeScript

import { get, set } from 'idb-keyval'
export const PENX_SESSION_DATA = 'PENX_SESSION_DATA'
export interface Session {
userId: string
address: string
email: string
role: string
user: {
name: string
email: string
image: string
id: string
}
}
export async function getLocalSession(): Promise<Session | undefined> {
try {
return await get(PENX_SESSION_DATA)
} catch (error) {
console.log('error1', error)
return undefined
}
}
export async function clearLocalSession() {
await set(PENX_SESSION_DATA, null)
}
export async function setLocalSession(session: Session) {
await set(PENX_SESSION_DATA, session)
}