Skip to content

Commit 6bb98cc

Browse files
alexjurkiewiczclaude
authored andcommitted
feat: auto-generate Sunshine Web UI password if none provided
Update the prompt to indicate that leaving the field blank will generate a password. If the user submits an empty value, a 32-character hex password is generated via crypto.randomBytes and printed to the console so the user can note it down. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b5c1a95 commit 6bb98cc

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

src/cli/prompter.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as os from 'os';
2+
import * as crypto from 'crypto';
23
import { PartialDeep } from "type-fest"
34
import { input, select, confirm, password } from '@inquirer/prompts';
45
import { ExitPromptError } from '@inquirer/core';
@@ -422,28 +423,28 @@ export abstract class AbstractInputPrompter<
422423
private async promptSunshinePasswordBase64(_sunshinePasswordBase64?: string): Promise<string> {
423424
if(_sunshinePasswordBase64){
424425
return _sunshinePasswordBase64
425-
} else {
426+
}
426427

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+
})
430431

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+
}
435437

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+
})
439441

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()
446445
}
446+
447+
return Buffer.from(sunshinePassword).toString('base64')
447448
}
448449

449450
private async promptAutoStop(_autoStopEnable?: boolean, _autostopTimeout?: number): Promise<{ autoStopEnable: boolean, autoStopTimeout?: number }> {

0 commit comments

Comments
 (0)