| 210 | } |
| 211 | |
| 212 | const jsonFrom = async <T>(response: Response, label: string): Promise<T> => { |
| 213 | const text = await response.text(); |
| 214 | if (!text) { |
| 215 | throw new Error(`${label}: empty response body (status ${response.status})`); |
| 216 | } |
| 217 | if (!response.ok) { |
| 218 | throw new Error(`${label}: request failed (status ${response.status}): ${text}`); |
| 219 | } |
| 220 | return JSON.parse(text) as T; |
| 221 | }; |
| 222 | |
| 223 | const mintBearerFlow = async (target: Target, email: string): Promise<string> => { |
| 224 | const consent = target.mcpConsent?.({ |