@@ -110,7 +110,7 @@ export class HttpError extends Error {
110
110
}
111
111
112
112
export interface ServerOptions {
113
- readonly auth ? : AuthType ;
113
+ readonly auth : AuthType ;
114
114
readonly basePath ?: string ;
115
115
readonly connectionToken ?: string ;
116
116
readonly cert ?: string ;
@@ -133,7 +133,7 @@ export abstract class Server {
133
133
134
134
public constructor ( options : ServerOptions ) {
135
135
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" ,
137
137
...options ,
138
138
basePath : options . basePath ? options . basePath . replace ( / \/ + $ / , "" ) : "" ,
139
139
} ;
@@ -269,7 +269,7 @@ export abstract class Server {
269
269
base = path . normalize ( base ) ;
270
270
requestPath = path . normalize ( requestPath || "/index.html" ) ;
271
271
272
- if ( base !== "/login" || ! this . options . auth || requestPath !== "/index.html" ) {
272
+ if ( base !== "/login" || this . options . auth !== "password" || requestPath !== "/index.html" ) {
273
273
this . ensureGet ( request ) ;
274
274
}
275
275
@@ -300,7 +300,7 @@ export abstract class Server {
300
300
response . cache = true ;
301
301
return response ;
302
302
case "/login" :
303
- if ( ! this . options . auth || requestPath !== "/index.html" ) {
303
+ if ( this . options . auth !== "password" || requestPath !== "/index.html" ) {
304
304
throw new HttpError ( "Not found" , HttpCode . NotFound ) ;
305
305
}
306
306
return this . tryLogin ( request ) ;
@@ -421,7 +421,7 @@ export abstract class Server {
421
421
}
422
422
423
423
private authenticate ( request : http . IncomingMessage , payload ?: LoginPayload ) : boolean {
424
- if ( ! this . options . auth ) {
424
+ if ( this . options . auth !== "password" ) {
425
425
return true ;
426
426
}
427
427
const safeCompare = localRequire < typeof import ( "safe-compare" ) > ( "safe-compare/index" ) ;
0 commit comments