Add OpenBao API client, session context and connect screen
CI / integration (push) Successful in 9s
CI / check (push) Successful in 13s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-20 11:05:59 +01:00
1 parent c5dbb78d1b
commit de36c97f36
9 files changed
+438 -4

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
import { useMemo, useState, type ReactNode } from 'react'
import type { BaoClient, TokenInfo } from './bao'
import { SessionContext, type Session } from './useSession'
// The token lives only in React state (memory); a page reload logs out.
export function SessionProvider({ children }: { children: ReactNode }) {
const [state, setState] = useState<{ client: BaoClient; tokenInfo: TokenInfo } | null>(null)
const value = useMemo<Session>(
() => ({
client: state?.client ?? null,
tokenInfo: state?.tokenInfo ?? null,
connect: (client, tokenInfo) => setState({ client, tokenInfo }),
disconnect: () => setState(null),
}),
[state],
)
return <SessionContext value={value}>{children}</SessionContext>
}