(target: TargetShape, path: string, identity: Identity, body: unknown)
| 67 | // responses re-seal the session when the active org changes. |
| 68 | |
| 69 | const postJson = (target: TargetShape, path: string, identity: Identity, body: unknown) => |
| 70 | Effect.promise(async () => { |
| 71 | const response = await fetch(new URL(path, target.baseUrl), { |
| 72 | method: "POST", |
| 73 | headers: { |
| 74 | // The identity's own headers (session cookie + org selector) exactly |
| 75 | // as its API client would send them — org-scoped endpoints fail |
| 76 | // closed without the selector. |
| 77 | ...(identity.headers ?? {}), |
| 78 | "content-type": "application/json", |
| 79 | origin: new URL(target.baseUrl).origin, |
| 80 | }, |
| 81 | body: JSON.stringify(body), |
| 82 | }); |
| 83 | if (!response.ok) { |
| 84 | throw new Error(`${path} failed (${response.status}): ${await response.text()}`); |
| 85 | } |
| 86 | return response; |
| 87 | }); |
| 88 | |
| 89 | /** The identity re-bound to the refreshed session cookie a response set, |
| 90 | * scoped to `orgSelector` via the selector header (see switchOrg). */ |
no test coverage detected