@@ -29,6 +29,7 @@ export interface Args extends VsArgs {
29
29
config ?: string
30
30
auth ?: AuthType
31
31
password ?: string
32
+ hashedPassword ?: string
32
33
cert ?: OptionalString
33
34
"cert-host" ?: string
34
35
"cert-key" ?: string
@@ -104,6 +105,12 @@ const options: Options<Required<Args>> = {
104
105
type : "string" ,
105
106
description : "The password for password authentication (can only be passed in via $PASSWORD or the config file)." ,
106
107
} ,
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
+ } ,
107
114
cert : {
108
115
type : OptionalString ,
109
116
path : true ,
@@ -279,6 +286,10 @@ export const parse = (
279
286
throw new Error ( "--password can only be set in the config file or passed in via $PASSWORD" )
280
287
}
281
288
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
+
282
293
const option = options [ key ]
283
294
if ( option . type === "boolean" ) {
284
295
; ( args [ key ] as boolean ) = true
@@ -361,6 +372,7 @@ export interface DefaultedArgs extends ConfigArgs {
361
372
"proxy-domain" : string [ ]
362
373
verbose : boolean
363
374
usingEnvPassword : boolean
375
+ usingEnvHashedPassword : boolean
364
376
"extensions-dir" : string
365
377
"user-data-dir" : string
366
378
}
@@ -448,13 +460,20 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
448
460
args [ "cert-key" ] = certKey
449
461
}
450
462
451
- const usingEnvPassword = ! ! process . env . PASSWORD
463
+ let usingEnvPassword = ! ! process . env . PASSWORD
452
464
if ( process . env . PASSWORD ) {
453
465
args . password = process . env . PASSWORD
454
466
}
455
467
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.
457
475
delete process . env . PASSWORD
476
+ delete process . env . HASHED_PASSWORD
458
477
459
478
// Filter duplicate proxy domains and remove any leading `*.`.
460
479
const proxyDomains = new Set ( ( args [ "proxy-domain" ] || [ ] ) . map ( ( d ) => d . replace ( / ^ \* \. / , "" ) ) )
@@ -463,6 +482,7 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
463
482
return {
464
483
...args ,
465
484
usingEnvPassword,
485
+ usingEnvHashedPassword,
466
486
} as DefaultedArgs // TODO: Technically no guarantee this is fulfilled.
467
487
}
468
488
0 commit comments