🎉 init

This commit is contained in:
2026-07-01 15:43:18 +02:00
commit 2f492c55be
64 changed files with 11645 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
const STORAGE_KEY = 'stb:identity'
export interface Identity {
name: string
}
type StorageLike = Pick<Storage, 'getItem' | 'setItem'>
export function readIdentity(storage: StorageLike): Identity | null {
const raw = storage.getItem(STORAGE_KEY)
if (!raw) return null
try {
const parsed = JSON.parse(raw)
if (typeof parsed?.name !== 'string' || !parsed.name.trim()) return null
return { name: parsed.name }
}
catch {
return null
}
}
export function writeIdentity(storage: StorageLike, identity: Identity): void {
storage.setItem(STORAGE_KEY, JSON.stringify(identity))
}