MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / generateLoginUrl

Function generateLoginUrl

cli/src/login/login-flow.ts:22–57  ·  view source on GitHub ↗
(
  deps: GenerateLoginUrlDeps,
  options: GenerateLoginUrlOptions,
)

Source from the content-addressed store, hash-verified

20}
21
22export async function generateLoginUrl(
23 deps: GenerateLoginUrlDeps,
24 options: GenerateLoginUrlOptions,
25): Promise<LoginUrlResponse> {
26 const { logger, apiClient: providedApiClient } = deps
27 const { baseUrl, fingerprintId } = options
28
29 const apiClient =
30 providedApiClient ??
31 createCodebuffApiClient({
32 baseUrl,
33 })
34
35 const response = await apiClient.loginCode({ fingerprintId })
36
37 if (!response.ok) {
38 logger.error(
39 {
40 status: response.status,
41 error: response.error,
42 },
43 '❌ Failed to request login URL',
44 )
45 throw new Error('Failed to get login URL')
46 }
47
48 if (!response.data) {
49 logger.error(
50 { status: response.status },
51 '❌ Empty response from login URL',
52 )
53 throw new Error('Failed to get login URL')
54 }
55
56 return response.data
57}
58
59interface PollLoginStatusDeps {
60 sleep: (ms: number) => Promise<void>

Callers 4

runPlainLoginFunction · 0.90
useFetchLoginUrlFunction · 0.90

Calls 2

createCodebuffApiClientFunction · 0.90
loginCodeMethod · 0.80

Tested by

no test coverage detected