|
1 | 1 | import * as os from 'os'; |
| 2 | +import * as crypto from 'crypto'; |
2 | 3 | import { PartialDeep } from "type-fest" |
3 | 4 | import { input, select, confirm, password } from '@inquirer/prompts'; |
4 | 5 | import { ExitPromptError } from '@inquirer/core'; |
@@ -422,28 +423,28 @@ export abstract class AbstractInputPrompter< |
422 | 423 | private async promptSunshinePasswordBase64(_sunshinePasswordBase64?: string): Promise<string> { |
423 | 424 | if(_sunshinePasswordBase64){ |
424 | 425 | return _sunshinePasswordBase64 |
425 | | - } else { |
| 426 | + } |
426 | 427 |
|
427 | | - const sunshinePassword = await password({ |
428 | | - message: "Enter Sunshine Web UI password:", |
429 | | - }) |
| 428 | + const sunshinePassword = await password({ |
| 429 | + message: "Enter Sunshine Web UI password (leave blank to generate one):", |
| 430 | + }) |
430 | 431 |
|
431 | | - if(sunshinePassword.length == 0){ |
432 | | - console.warn("Password cannot be empty.") |
433 | | - return this.promptSunshinePasswordBase64() |
434 | | - } |
| 432 | + if(sunshinePassword.length == 0){ |
| 433 | + const generated = crypto.randomBytes(16).toString('hex') |
| 434 | + console.info(`Generated Sunshine Web UI password: ${generated}`) |
| 435 | + return Buffer.from(generated).toString('base64') |
| 436 | + } |
435 | 437 |
|
436 | | - const sunshinePasswordConfirm = await password({ |
437 | | - message: "Confirm Sunshine Web UI password:", |
438 | | - }) |
| 438 | + const sunshinePasswordConfirm = await password({ |
| 439 | + message: "Confirm Sunshine Web UI password:", |
| 440 | + }) |
439 | 441 |
|
440 | | - if(sunshinePassword !== sunshinePasswordConfirm){ |
441 | | - console.warn("Passwords do not match.") |
442 | | - return this.promptSunshinePasswordBase64() |
443 | | - } |
444 | | - |
445 | | - return Buffer.from(sunshinePassword).toString('base64') |
| 442 | + if(sunshinePassword !== sunshinePasswordConfirm){ |
| 443 | + console.warn("Passwords do not match.") |
| 444 | + return this.promptSunshinePasswordBase64() |
446 | 445 | } |
| 446 | + |
| 447 | + return Buffer.from(sunshinePassword).toString('base64') |
447 | 448 | } |
448 | 449 |
|
449 | 450 | private async promptAutoStop(_autoStopEnable?: boolean, _autostopTimeout?: number): Promise<{ autoStopEnable: boolean, autoStopTimeout?: number }> { |
|
0 commit comments