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

Function signIn

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

Source from the content-addressed store, hash-verified

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