(email: string, password: string)
| 56 | // on 401: request() retries via login() on 401, which would loop forever if |
| 57 | // credentials were invalid. |
| 58 | async login(email: string, password: string): Promise<string> { |
| 59 | const resp = await fetch(`${this.baseURL}/v1/auth/login`, { |
| 60 | method: "POST", |
| 61 | headers: { "Content-Type": "application/json" }, |
| 62 | body: JSON.stringify({ email, password }), |
| 63 | }); |
| 64 | if (!resp.ok) { |
| 65 | throw new Error(`API POST /v1/auth/login failed (${resp.status}): ${await resp.text()}`); |
| 66 | } |
| 67 | const { token } = (await resp.json()) as { token: string }; |
| 68 | this.token = token; |
| 69 | this.credentials = { email, password }; |
| 70 | return token; |
| 71 | } |
| 72 | |
| 73 | // Signup creates the first user on a fresh server. The first user becomes |
| 74 | // workspace admin. Signup always sets cookies (no body token), so callers |
no outgoing calls
no test coverage detected