(auth: { initData: string; accessToken: string })
| 168 | } |
| 169 | |
| 170 | async bind(auth: { initData: string; accessToken: string }): Promise<AuthResponse> { |
| 171 | const res = await fetch(this.buildUrl('/api/bind'), { |
| 172 | method: 'POST', |
| 173 | headers: { 'content-type': 'application/json' }, |
| 174 | body: JSON.stringify(auth) |
| 175 | }) |
| 176 | |
| 177 | if (!res.ok) { |
| 178 | const body = await res.text().catch(() => '') |
| 179 | const code = parseErrorCode(body) |
| 180 | const detail = body ? `: ${body}` : '' |
| 181 | throw new ApiError(`Bind failed: HTTP ${res.status} ${res.statusText}${detail}`, res.status, code, body || undefined) |
| 182 | } |
| 183 | |
| 184 | return await res.json() as AuthResponse |
| 185 | } |
| 186 | |
| 187 | async getSessions(): Promise<SessionsResponse> { |
| 188 | return await this.request<SessionsResponse>('/api/sessions') |
no test coverage detected