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

Function completeLogin

e2e/cloud/unauthenticated-skeleton.test.ts:90–112  ·  view source on GitHub ↗
(loginQuery: string)

Source from the content-addressed store, hash-verified

88 // the signed-in browser. returnTo rides INSIDE the OAuth state param the
89 // whole way — the state cookie is the only thing the browser carries.
90 const completeLogin = (loginQuery: string) =>
91 Effect.promise(async () => {
92 const login = await fetch(new URL(`/api/auth/login${loginQuery}`, target.baseUrl), {
93 redirect: "manual",
94 });
95 expect(login.status, "login hands the browser to AuthKit").toBe(302);
96 const stateCookie = cookiePair(login, "wos-login-state");
97 expect(stateCookie, "the CSRF state is pinned in a cookie").toBeTruthy();
98
99 const authorizeUrl = new URL(login.headers.get("location") ?? "");
100 authorizeUrl.searchParams.set("login_hint", `returnto-${Date.now()}@e2e.test`);
101 const consent = await fetch(authorizeUrl, { redirect: "manual" });
102 const callbackUrl = consent.headers.get("location");
103 expect(callbackUrl, "AuthKit redirects back to the app's callback").toBeTruthy();
104
105 const callback = await fetch(callbackUrl!, {
106 redirect: "manual",
107 headers: { cookie: stateCookie! },
108 });
109 expect(callback.status, "the callback completes the login").toBe(302);
110 expect(cookiePair(callback, "wos-session"), "a real session cookie is minted").toBeTruthy();
111 return callback.headers.get("location");
112 });
113
114 // 2. Completing the hosted flow resumes exactly where the gate
115 // interrupted the visitor — the deep link, not "/".

Calls 4

cookiePairFunction · 0.70
getMethod · 0.65
setMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected