(baseUrl: string, cookie: string, name: string)
| 115 | }); |
| 116 | |
| 117 | const createOrganization = (baseUrl: string, cookie: string, name: string) => |
| 118 | Effect.promise(async () => { |
| 119 | const response = await fetch(new URL("/api/auth/create-organization", baseUrl), { |
| 120 | method: "POST", |
| 121 | headers: { |
| 122 | "content-type": "application/json", |
| 123 | cookie, |
| 124 | ...originHeaders(baseUrl), |
| 125 | }, |
| 126 | body: JSON.stringify({ name }), |
| 127 | }); |
| 128 | if (!response.ok) { |
| 129 | throw new Error(`/api/auth/create-organization failed (${response.status})`); |
| 130 | } |
| 131 | const session = cookiePair(response, "wos-session"); |
| 132 | if (!session) throw new Error("create organization did not refresh the session"); |
| 133 | const org = (await response.json()) as { id: string; name: string; slug: string }; |
| 134 | return { org, session }; |
| 135 | }); |
| 136 | |
| 137 | const oauthIntegrationSpec = (oauth: { |
| 138 | readonly authorizationEndpoint: string; |
no test coverage detected