MCPcopy
hub / github.com/upstash/context7 / renderDeviceCodeBox

Function renderDeviceCodeBox

packages/cli/src/commands/auth.ts:49–69  ·  view source on GitHub ↗
(
  userCode: string,
  verificationUri: string,
  verificationUriComplete: string | undefined
)

Source from the content-addressed store, hash-verified

47}
48
49function renderDeviceCodeBox(
50 userCode: string,
51 verificationUri: string,
52 verificationUriComplete: string | undefined
53): string {
54 const codeLine = `${pc.dim("Your one-time code:")}\n\n ${pc.green(pc.bold(userCode))}`;
55 // Per RFC 8628 §3.3, even when verification_uri_complete is available we
56 // still show the bare verification_uri so users on screen readers / paper
57 // can type it manually.
58 const linkLine = verificationUriComplete
59 ? `${pc.dim("Open this link to approve:")}\n${pc.cyan(verificationUriComplete)}\n\n${pc.dim("Or visit")} ${pc.cyan(verificationUri)} ${pc.dim("and enter the code above.")}`
60 : `${pc.dim("Visit:")} ${pc.cyan(verificationUri)}`;
61 return boxen(`${codeLine}\n\n${linkLine}`, {
62 title: "Sign in to Context7",
63 titleAlignment: "left",
64 padding: 1,
65 margin: { top: 1, bottom: 1, left: 2, right: 2 },
66 borderStyle: "round",
67 borderColor: "gray",
68 });
69}
70
71/** Prints a prompt and resolves on the next keypress. No-op when stdin isn't a TTY. */
72function waitForEnter(prompt: string): Promise<void> {

Callers 1

performLoginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected