SDK (Web)
EntityAuthClient methods and usage
SDK (Web)
Construct with optional { baseURL }
. All methods mirror /api/*
routes.
import { EntityAuthClient } from "@/packages/sdk/src";
const ea = new EntityAuthClient({ baseURL: "https://api.example.com" });
Auth
register({ email, password, tenantId })
login({ email, password, tenantId })
→ sets access tokenrefresh(headerRefreshToken?)
logout()
Orgs
createOrg({ tenantId, name, slug, ownerId })
addMember({ orgId, userId, role })
switchOrg({ orgId })
Users
getUserMe()
userByUsername({ username })
userByEmail({ email })
setUsername({ username })
checkUsername({ value })
→{ valid, available }
Helpers
onTokenChange(listener)
andgetAccessToken()
openapi()
to inspect the server schema
Best practices
Use EntityAuthClient.fetch
for authenticated requests so 401s auto‑refresh the token.
Token storage
Avoid persisting access tokens in localStorage; the SDK keeps them in memory and refreshes when needed.