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

Function responseCookies

e2e/cloud/support/admin-mfa.ts:20–32  ·  view source on GitHub ↗
(current: string, response: Response)

Source from the content-addressed store, hash-verified

18
19/** Apply response cookie rotations and deletions to a test client's cookie header. */
20export const responseCookies = (current: string, response: Response): string => {
21 const cookies = new Map(browserCookies(current).map(({ name, value }) => [name, value]));
22 for (const header of response.headers.getSetCookie()) {
23 const pair = header.split(";")[0];
24 if (!pair) throw new Error("Empty response cookie");
25 const separator = pair.indexOf("=");
26 if (separator < 1) throw new Error("Invalid response cookie");
27 const name = pair.slice(0, separator);
28 if (/;\s*max-age=0(?:;|$)/i.test(header)) cookies.delete(name);
29 else cookies.set(name, pair.slice(separator + 1));
30 }
31 return [...cookies].map(([name, value]) => `${name}=${value}`).join("; ");
32};
33
34/** Read all cookie pairs, including admin verification, into browser fixtures. */
35export const browserCookies = (cookie: string): NonNullable<Identity["cookies"]> =>

Callers 3

verifyAdminFunction · 0.85

Calls 3

browserCookiesFunction · 0.85
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected