mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-11-01 07:02:53 +00:00
29 lines
600 B
TypeScript
29 lines
600 B
TypeScript
"use client"
|
|
|
|
import { invoke } from "@tauri-apps/api/core"
|
|
|
|
export type AuthSession = {
|
|
userId: string
|
|
email?: string
|
|
name?: string
|
|
apiUrl: string
|
|
}
|
|
|
|
export const desktopDevAuthEnabled = process.env.NEXT_PUBLIC_DESKTOP_DEV === "1"
|
|
|
|
export async function getStoredToken() {
|
|
return invoke<string | null>("auth_get_token")
|
|
}
|
|
|
|
export async function getSession() {
|
|
return invoke<AuthSession>("auth_whoami")
|
|
}
|
|
|
|
export async function storeToken(token: string) {
|
|
await invoke("auth_store_token", { token })
|
|
return getSession()
|
|
}
|
|
|
|
export async function clearSession() {
|
|
await invoke("auth_clear")
|
|
}
|