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