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

Function authHeaders

e2e/scenarios/custom-tools.test.ts:140–156  ·  view source on GitHub ↗
(
  target: TargetShape,
  identity: Identity,
)

Source from the content-addressed store, hash-verified

138}
139
140const authHeaders = async (
141 target: TargetShape,
142 identity: Identity,
143): Promise<Record<string, string>> => {
144 if (identity.headers) return identity.headers;
145 const credentials = identity.credentials;
146 if (!credentials) throw new Error(`identity ${identity.label} has no credentials`);
147 const response = await fetch(new URL("/api/auth/sign-in/email", target.baseUrl), {
148 method: "POST",
149 headers: { "content-type": "application/json", origin: new URL(target.baseUrl).origin },
150 body: JSON.stringify(credentials),
151 redirect: "manual",
152 });
153 const cookie = (response.headers.getSetCookie?.() ?? []).map((c) => c.split(";")[0]).join("; ");
154 if (!cookie) throw new Error(`sign-in set no cookie (${response.status})`);
155 return { cookie };
156};
157
158const request = async <T>(
159 target: TargetShape,

Callers 1

requestFunction · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected