MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / signInHeaders

Function signInHeaders

e2e/src/surfaces/api.ts:43–56  ·  view source on GitHub ↗
(baseUrl: string, identity: Identity)

Source from the content-addressed store, hash-verified

41// Better Auth email sign-in → session cookie (selfhost). The `origin` header is
42// required: Better Auth rejects state-changing requests without one.
43const signInHeaders = (baseUrl: string, identity: Identity) =>
44 Effect.promise(async (): Promise<Record<string, string>> => {
45 const credentials = identity.credentials;
46 if (!credentials) throw new Error(`identity ${identity.label} has no headers or credentials`);
47 const response = await fetch(new URL("/api/auth/sign-in/email", baseUrl), {
48 method: "POST",
49 headers: { "content-type": "application/json", origin: new URL(baseUrl).origin },
50 body: JSON.stringify(credentials),
51 redirect: "manual",
52 });
53 const cookie = (response.headers.getSetCookie?.() ?? []).map((c) => c.split(";")[0]).join("; ");
54 if (!cookie) throw new Error(`api: sign-in set no cookie (${response.status})`);
55 return { cookie };
56 });

Callers 1

makeApiSurfaceFunction · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected