@@ -110,7 +110,7 @@ export class HttpError extends Error {
110110}
111111
112112export interface ServerOptions {
113- readonly auth ? : AuthType ;
113+ readonly auth : AuthType ;
114114 readonly basePath ?: string ;
115115 readonly connectionToken ?: string ;
116116 readonly cert ?: string ;
@@ -133,7 +133,7 @@ export abstract class Server {
133133
134134 public constructor ( options : ServerOptions ) {
135135 this . options = {
136- host : options . auth && options . cert ? "0.0.0.0" : "localhost" ,
136+ host : options . auth === "password" && options . cert ? "0.0.0.0" : "localhost" ,
137137 ...options ,
138138 basePath : options . basePath ? options . basePath . replace ( / \/ + $ / , "" ) : "" ,
139139 } ;
@@ -269,7 +269,7 @@ export abstract class Server {
269269 base = path . normalize ( base ) ;
270270 requestPath = path . normalize ( requestPath || "/index.html" ) ;
271271
272- if ( base !== "/login" || ! this . options . auth || requestPath !== "/index.html" ) {
272+ if ( base !== "/login" || this . options . auth !== "password" || requestPath !== "/index.html" ) {
273273 this . ensureGet ( request ) ;
274274 }
275275
@@ -300,7 +300,7 @@ export abstract class Server {
300300 response . cache = true ;
301301 return response ;
302302 case "/login" :
303- if ( ! this . options . auth || requestPath !== "/index.html" ) {
303+ if ( this . options . auth !== "password" || requestPath !== "/index.html" ) {
304304 throw new HttpError ( "Not found" , HttpCode . NotFound ) ;
305305 }
306306 return this . tryLogin ( request ) ;
@@ -421,7 +421,7 @@ export abstract class Server {
421421 }
422422
423423 private authenticate ( request : http . IncomingMessage , payload ?: LoginPayload ) : boolean {
424- if ( ! this . options . auth ) {
424+ if ( this . options . auth !== "password" ) {
425425 return true ;
426426 }
427427 const safeCompare = localRequire < typeof import ( "safe-compare" ) > ( "safe-compare/index" ) ;
0 commit comments