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

Function signIn

apps/cloud/src/auth/mirror-feeders.node.test.ts:220–263  ·  view source on GitHub ↗
(user: ReturnType<typeof workosUser>, listed: readonly FakeMembership[])

Source from the content-addressed store, hash-verified

218 * is assertable from the outside.
219 */
220 const signIn = (user: ReturnType<typeof workosUser>, listed: readonly FakeMembership[]) => {
221 const calls: string[] = [];
222 const refreshedInto: (string | undefined)[] = [];
223 const handler = callbackHandler(
224 stubWorkOS({
225 authenticateWithCode: () =>
226 Effect.succeed({
227 user,
228 organizationId: undefined,
229 accessToken: "access",
230 refreshToken: "refresh",
231 sealedSession: "sealed",
232 }),
233 listUserMemberships: (id) => {
234 calls.push(`listUserMemberships:${id}`);
235 return Effect.succeed({
236 object: "list" as const,
237 data: listed as never[],
238 listMetadata: { before: null, after: null },
239 });
240 },
241 // The landing org's seat recount scans the org from WorkOS the first
242 // time it is counted (its per-org backfill mark is missing); the
243 // scan lists the org's members and fetches each user.
244 listOrgMembers: (organizationId) => {
245 calls.push(`listOrgMembers:${organizationId}`);
246 return Effect.succeed({
247 object: "list" as const,
248 data: listed.filter((m) => m.organizationId === organizationId) as never[],
249 listMetadata: { before: null, after: null },
250 });
251 },
252 getUser: (id) => {
253 calls.push(`getUser:${id}`);
254 return Effect.succeed(workosUser(id) as never);
255 },
256 refreshSession: (_sealed, organizationId) => {
257 refreshedInto.push(organizationId);
258 return Effect.succeed("sealed-refreshed");
259 },
260 }),
261 );
262 return { handler, calls, refreshedInto };
263 };
264
265 /**
266 * `GET /auth/callback` with the CSRF-matched login `state` (the callback

Callers 1

Calls 4

callbackHandlerFunction · 0.85
pushMethod · 0.80
stubWorkOSFunction · 0.70
workosUserFunction · 0.70

Tested by

no test coverage detected