()
| 80 | } |
| 81 | |
| 82 | async createTunnel() { |
| 83 | const response = await fetch(`${this.baseUrl}/api/v1/tunnels`, { |
| 84 | method: "POST", |
| 85 | headers: { |
| 86 | Accept: "application/json", |
| 87 | Authorization: `Bearer ${this.apiKey}`, |
| 88 | }, |
| 89 | }); |
| 90 | |
| 91 | if (!response.ok) { |
| 92 | throw new Error(`Could not create tunnel: ${response.status}`); |
| 93 | } |
| 94 | |
| 95 | const body = await response.json(); |
| 96 | |
| 97 | const parsedBody = CreateTunnelResponseSchema.safeParse(body); |
| 98 | |
| 99 | if (!parsedBody.success) { |
| 100 | throw new Error(`Could not create tunnel: ${parsedBody.error.message}`); |
| 101 | } |
| 102 | |
| 103 | return parsedBody.data; |
| 104 | } |
| 105 | |
| 106 | async whoami(): Promise<WhoamiResponse | undefined> { |
| 107 | const response = await fetch(`${this.baseUrl}/api/v1/whoami`, { |
no test coverage detected