MCPcopy
hub / github.com/lingodotdev/lingo.dev / login

Function login

packages/cli/src/cli/cmd/login.ts:42–75  ·  view source on GitHub ↗
(apiUrl: string)

Source from the content-addressed store, hash-verified

40 });
41
42export async function login(apiUrl: string) {
43 await readline
44 .createInterface({
45 input: process.stdin,
46 output: process.stdout,
47 })
48 .question(
49 `
50Press Enter to open the browser for authentication.
51
52---
53
54Having issues? Put LINGO_API_KEY in your .env file instead.
55 `.trim() + "\n",
56 );
57
58 const verifier = randomBytes(32).toString("base64url");
59
60 const createSpinner = Ora().start("Starting authentication session");
61 const session = await createCliSession(apiUrl, verifier);
62 createSpinner.succeed("Authentication session started");
63
64 await open(session.verifyUrl, { wait: false });
65
66 const pollSpinner = Ora().start("Waiting for browser confirmation");
67 try {
68 const apiKey = await pollForApiKey(apiUrl, session.id, verifier);
69 pollSpinner.succeed("API key received");
70 return apiKey;
71 } catch (error) {
72 pollSpinner.fail();
73 throw error;
74 }
75}
76
77type CreateSessionResponse = {
78 id: string;

Callers 2

init.tsFile · 0.90
login.tsFile · 0.85

Calls 4

createCliSessionFunction · 0.85
pollForApiKeyFunction · 0.85
toStringMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected