认证

获取当前用户

GET /api/auth/me

返回当前已认证的用户信息。

响应:

{
  "id": "uuid",
  "username": "alice",
  "displayName": "Alice",
  "avatarUrl": "https://...",
  "isBot": false
}
const me = await client.getMe()
me = client.get_me()

更新个人资料

PATCH /api/auth/me
字段类型说明
displayNamestring显示名称
avatarUrlstring | null头像 URL
const updated = await client.updateProfile({
  displayName: 'New Name',
  avatarUrl: 'https://example.com/avatar.png',
})
updated = client.update_profile(
    display_name="New Name",
    avatar_url="https://example.com/avatar.png",
)

获取用户资料

GET /api/auth/users/:id

通过 ID 获取公开的用户资料。

const profile = await client.getUserProfile('user-id')
profile = client.get_user_profile("user-id")

注册

POST /api/auth/register

无需认证。

字段类型必填说明
emailstring邮箱地址
passwordstring密码
usernamestring唯一用户名
displayNamestring显示名称
inviteCodestring有效邀请码
const { token, user } = await client.register({
  email: '[email protected]',
  password: 'secure-password',
  username: 'alice',
  inviteCode: 'ABC123',
})
result = client.register(
    email="[email protected]",
    password="secure-password",
    username="alice",
    invite_code="ABC123",
)
token = result["token"]

登录

POST /api/auth/login

无需认证。

字段类型必填
emailstring
passwordstring
const { token, user } = await client.login({
  email: '[email protected]',
  password: 'secret',
})
result = client.login(email="[email protected]", password="secret")

刷新令牌

POST /api/auth/refresh

返回新的 JWT 令牌。

const { token } = await client.refreshToken()
result = client.refresh_token()

断开连接

POST /api/auth/disconnect

通知服务器客户端正在断开连接(用于在线状态跟踪)。

await client.disconnect()
client.disconnect()