MCPcopy Create free account
hub / github.com/tiann/hapi / promptForToken

Function promptForToken

cli/src/ui/tokenInit.ts:53–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51}
52
53async function promptForToken(): Promise<string> {
54 const rl = readline.createInterface({ input, output })
55
56 console.log(chalk.yellow('\nNo CLI_API_TOKEN found.'))
57 console.log(chalk.gray('Where to find the token:'))
58 console.log(chalk.gray(' 1. Check the server startup logs (first run shows generated token)'))
59 console.log(chalk.gray(' 2. Read ~/.hapi/settings.json on the server'))
60 console.log(chalk.gray(' 3. Ask your server administrator (if token is set via env var)\n'))
61
62 try {
63 const token = await rl.question(chalk.cyan('Enter CLI_API_TOKEN: '))
64 if (!token.trim()) {
65 throw new Error('Token cannot be empty')
66 }
67 console.log(chalk.green(`\nToken saved to ${configuration.settingsFile}`))
68 return token.trim()
69 } finally {
70 rl.close()
71 }
72}

Callers 1

initializeTokenFunction · 0.85

Calls 1

closeMethod · 0.65

Tested by

no test coverage detected