@@ -29,6 +29,7 @@ export interface Args extends VsArgs {
2929 config ?: string
3030 auth ?: AuthType
3131 password ?: string
32+ hashedPassword ?: string
3233 cert ?: OptionalString
3334 "cert-host" ?: string
3435 "cert-key" ?: string
@@ -104,6 +105,12 @@ const options: Options<Required<Args>> = {
104105 type : "string" ,
105106 description : "The password for password authentication (can only be passed in via $PASSWORD or the config file)." ,
106107 } ,
108+ hashedPassword : {
109+ type : "string" ,
110+ description :
111+ "The password hashed with SHA-256 for password authentication (can only be passed in via $HASHED_PASSWORD or the config file). \n" +
112+ "Takes precedence over 'password'." ,
113+ } ,
107114 cert : {
108115 type : OptionalString ,
109116 path : true ,
@@ -279,6 +286,10 @@ export const parse = (
279286 throw new Error ( "--password can only be set in the config file or passed in via $PASSWORD" )
280287 }
281288
289+ if ( key === "hashedPassword" && ! opts ?. configFile ) {
290+ throw new Error ( "--hashedPassword can only be set in the config file or passed in via $HASHED_PASSWORD" )
291+ }
292+
282293 const option = options [ key ]
283294 if ( option . type === "boolean" ) {
284295 ; ( args [ key ] as boolean ) = true
@@ -361,6 +372,7 @@ export interface DefaultedArgs extends ConfigArgs {
361372 "proxy-domain" : string [ ]
362373 verbose : boolean
363374 usingEnvPassword : boolean
375+ usingEnvHashedPassword : boolean
364376 "extensions-dir" : string
365377 "user-data-dir" : string
366378}
@@ -448,13 +460,20 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
448460 args [ "cert-key" ] = certKey
449461 }
450462
451- const usingEnvPassword = ! ! process . env . PASSWORD
463+ let usingEnvPassword = ! ! process . env . PASSWORD
452464 if ( process . env . PASSWORD ) {
453465 args . password = process . env . PASSWORD
454466 }
455467
456- // Ensure it's not readable by child processes.
468+ const usingEnvHashedPassword = ! ! process . env . HASHED_PASSWORD
469+ if ( process . env . HASHED_PASSWORD ) {
470+ args . hashedPassword = process . env . HASHED_PASSWORD
471+ usingEnvPassword = false
472+ }
473+
474+ // Ensure they're not readable by child processes.
457475 delete process . env . PASSWORD
476+ delete process . env . HASHED_PASSWORD
458477
459478 // Filter duplicate proxy domains and remove any leading `*.`.
460479 const proxyDomains = new Set ( ( args [ "proxy-domain" ] || [ ] ) . map ( ( d ) => d . replace ( / ^ \* \. / , "" ) ) )
@@ -463,6 +482,7 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
463482 return {
464483 ...args ,
465484 usingEnvPassword,
485+ usingEnvHashedPassword,
466486 } as DefaultedArgs // TODO: Technically no guarantee this is fulfilled.
467487}
468488
0 commit comments