feat: expose account registration, login and admin recovery over HTTP

This commit is contained in:
DiheChen committed 2026-11-08 22:01:12 +08:00
1 parent b8d9fac4c3
commit 791171d5ab
17 files changed
+1459 -53

No files matched your search

+44 -1
View File
@@ -1,6 +1,6 @@
// Code generated by protocolgen from protocol/idl.json; DO NOT EDIT.
import type { APIKey, ErrorInfo, Member, QQLoginType, QRLogin, QRLoginResult, RoomListing, SourceAccount, StoredMedia } from '../realtime/protocol.gen'
import type { APIKey, Account, AdminAccount, ErrorInfo, Member, QQLoginType, QRLogin, QRLoginResult, RoomListing, SourceAccount, StoredMedia } from '../realtime/protocol.gen'
export interface AdminCheckBilibiliLoginRequest {
key: string
@@ -59,6 +59,14 @@ export interface AdminListRoomsResponse {
items: RoomListing[]
}
export type AdminOpenRegistrationRequest = Record<string, never>
export type AdminResetAccountPasswordRequest = Record<string, never>
export interface AdminResetAccountPasswordResponse {
password: string
}
export type AdminResetRoomApiKeyRequest = Record<string, never>
export interface AdminSetYoutubeCredentialRequest {
@@ -88,6 +96,11 @@ export interface AdminUpdateSiteResponse {
brandName: string
}
export interface ChangePasswordRequest {
currentPassword: string
newPassword: string
}
export type CreateMemberRequest = Record<string, never>
export interface CreateMemberResponse {
@@ -114,17 +127,39 @@ export interface CreateTicketResponse {
}
export interface GetMeResponse {
account?: Account
member: Member
}
export interface GetSiteResponse {
brandName: string
registrationOpen: boolean
}
export interface ListRoomsResponse {
items: RoomListing[]
}
export interface LoginRequest {
password: string
username: string
}
export interface LoginResponse {
account: Account
member: Member
memberToken: string
}
export interface RegisterRequest {
password: string
username: string
}
export interface RegisterResponse {
account: Account
}
export interface UpdateMeRequest {
email?: string
name?: string
@@ -154,6 +189,10 @@ export function httpClient(send: HttpSend) {
createMember: () => send<CreateMemberResponse>({ method: 'POST', path: '/api/members', auth: 'none', body: {} }),
getMe: () => send<GetMeResponse>({ method: 'GET', path: '/api/me', auth: 'member' }),
updateMe: (body: UpdateMeRequest) => send<UpdateMeResponse>({ method: 'PATCH', path: '/api/me', auth: 'member', body }),
register: (body: RegisterRequest) => send<RegisterResponse>({ method: 'POST', path: '/api/account', auth: 'member', body }),
changePassword: (body: ChangePasswordRequest) => send<void>({ method: 'PUT', path: '/api/account/password', auth: 'member', body }),
login: (body: LoginRequest) => send<LoginResponse>({ method: 'POST', path: '/api/sessions', auth: 'member', body }),
logout: () => send<void>({ method: 'DELETE', path: '/api/sessions/current', auth: 'member' }),
listRooms: () => send<ListRoomsResponse>({ method: 'GET', path: '/api/rooms', auth: 'none' }),
getRoom: (ref: string) => send<RoomListing>({ method: 'GET', path: `/api/rooms/${encodeURIComponent(ref)}`, auth: 'none' }),
createRoom: (body: CreateRoomRequest) => send<CreateRoomResponse>({ method: 'POST', path: '/api/rooms', auth: 'none', body }),
@@ -180,5 +219,9 @@ export function httpClient(send: HttpSend) {
adminListMedia: () => send<AdminListMediaResponse>({ method: 'GET', path: '/api/admin/media', auth: 'admin' }),
adminDeleteMedia: (key: string) => send<void>({ method: 'DELETE', path: `/api/admin/media/${encodeURIComponent(key)}`, auth: 'admin' }),
adminUpdateSite: (body: AdminUpdateSiteRequest) => send<AdminUpdateSiteResponse>({ method: 'PATCH', path: '/api/admin/site', auth: 'admin', body }),
adminOpenRegistration: () => send<void>({ method: 'PUT', path: '/api/admin/registration', auth: 'admin', body: {} }),
adminCloseRegistration: () => send<void>({ method: 'DELETE', path: '/api/admin/registration', auth: 'admin' }),
adminGetAccount: (username: string) => send<AdminAccount>({ method: 'GET', path: `/api/admin/accounts/${encodeURIComponent(username)}`, auth: 'admin' }),
adminResetAccountPassword: (username: string) => send<AdminResetAccountPasswordResponse>({ method: 'POST', path: `/api/admin/accounts/${encodeURIComponent(username)}/password`, auth: 'admin', body: {} }),
}
}
+12 -2
View File
@@ -1,13 +1,23 @@
// Code generated by protocolgen from protocol/idl.json; DO NOT EDIT.
export const PROTOCOL_VERSION = '473ee31f5ef912b4'
export const PROTOCOL_VERSION = 'eae091a3e1daf18c'
export interface APIKey {
key: string
}
export interface Account {
email?: string
username: string
}
export type ActivityKind = 'added' | 'removed' | 'liked' | 'voted' | 'skipped' | 'failed'
export interface AdminAccount {
member: Member
username: string
}
export interface ChatMessageEvent {
content: string
member: Member
@@ -32,7 +42,7 @@ export interface Entry {
export type EntryStatus = 'preparing' | 'ready'
export type ErrorCode = 'INVALID_ARGUMENT' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'CONFLICT' | 'QUEUE_FULL' | 'NOTHING_PLAYING' | 'RATE_LIMITED' | 'PROVIDER_ERROR' | 'UNAVAILABLE' | 'CLIENT_OUTDATED' | 'INTERNAL'
export type ErrorCode = 'INVALID_ARGUMENT' | 'UNAUTHORIZED' | 'INVALID_CREDENTIALS' | 'FORBIDDEN' | 'NOT_FOUND' | 'CONFLICT' | 'QUEUE_FULL' | 'NOTHING_PLAYING' | 'RATE_LIMITED' | 'PROVIDER_ERROR' | 'UNAVAILABLE' | 'CLIENT_OUTDATED' | 'INTERNAL'
export interface ErrorInfo {
code: ErrorCode