MCPcopy Index your code
hub / github.com/coder/mux / createSessionViaGithubDeviceFlow

Function createSessionViaGithubDeviceFlow

src/node/services/serverAuthService.test.ts:83–106  ·  view source on GitHub ↗
(
    service: ServerAuthService,
    opts?: { userAgent?: string; ipAddress?: string }
  )

Source from the content-addressed store, hash-verified

81 });
82
83 async function createSessionViaGithubDeviceFlow(
84 service: ServerAuthService,
85 opts?: { userAgent?: string; ipAddress?: string }
86 ): Promise<{ sessionId: string; sessionToken: string }> {
87 setMockFetchForSuccessfulGithubLogin();
88
89 const startResult = await service.startGithubDeviceFlow();
90 expect(startResult.success).toBe(true);
91 if (!startResult.success) {
92 throw new Error(`startGithubDeviceFlow failed: ${startResult.error}`);
93 }
94
95 const waitResult = await service.waitForGithubDeviceFlow(startResult.data.flowId, {
96 userAgent: opts?.userAgent,
97 ipAddress: opts?.ipAddress,
98 });
99
100 expect(waitResult.success).toBe(true);
101 if (!waitResult.success) {
102 throw new Error(`waitForGithubDeviceFlow failed: ${waitResult.error}`);
103 }
104
105 return waitResult.data;
106 }
107
108 function createService(configOverride?: Config): ServerAuthService {
109 const service = new ServerAuthService(configOverride ?? config);

Callers 1

Tested by

no test coverage detected