@@ -201,7 +201,7 @@ export namespace R { // responses
201
201
export class Api {
202
202
203
203
public static err = {
204
- eli5 : ( e : any ) => {
204
+ eli5 : ( e : unknown ) => {
205
205
if ( Api . err . isMailOrAcctDisabled ( e ) ) {
206
206
return 'Email account is disabled' ;
207
207
} else if ( Api . err . isAuthPopupNeeded ( e ) ) {
@@ -228,7 +228,7 @@ export class Api {
228
228
return 'FlowCrypt encountered an error with unknown cause.' ;
229
229
}
230
230
} ,
231
- detailsAsHtmlWithNewlines : ( e : any ) => {
231
+ detailsAsHtmlWithNewlines : ( e : unknown ) => {
232
232
let details = 'Below are technical details about the error. This may be useful for debugging.\n\n' ;
233
233
details += `<b>Error string</b>: ${ Xss . escape ( String ( e ) ) } \n\n` ;
234
234
details += `<b>Error stack</b>: ${ e instanceof Error ? Xss . escape ( ( e . stack || '(empty)' ) ) : '(no error stack)' } \n\n` ;
@@ -237,7 +237,7 @@ export class Api {
237
237
}
238
238
return details ;
239
239
} ,
240
- isNetErr : ( e : any ) => {
240
+ isNetErr : ( e : unknown ) => {
241
241
if ( e instanceof TypeError && ( e . message === 'Failed to fetch' || e . message === 'NetworkError when attempting to fetch resource.' ) ) {
242
242
return true ; // openpgp.js uses fetch()... which produces these errors
243
243
}
@@ -249,7 +249,7 @@ export class Api {
249
249
}
250
250
return false ;
251
251
} ,
252
- isAuthErr : ( e : any ) => {
252
+ isAuthErr : ( e : unknown ) => {
253
253
if ( e instanceof AuthError ) {
254
254
return true ;
255
255
}
@@ -263,7 +263,7 @@ export class Api {
263
263
}
264
264
return false ;
265
265
} ,
266
- isStandardErr : ( e : any , internalType : string ) => {
266
+ isStandardErr : ( e : unknown , internalType : string ) => {
267
267
if ( e instanceof ApiErrorResponse && typeof e . res === 'object' && typeof e . res . error === 'object' && e . res . error . internal === 'auth' ) {
268
268
return true ;
269
269
}
@@ -275,7 +275,7 @@ export class Api {
275
275
}
276
276
return false ;
277
277
} ,
278
- isAuthPopupNeeded : ( e : any ) => {
278
+ isAuthPopupNeeded : ( e : unknown ) => {
279
279
if ( e instanceof AjaxError && e . status === 400 && typeof e . responseText === 'string' ) {
280
280
try {
281
281
const json = JSON . parse ( e . responseText ) ;
@@ -289,18 +289,18 @@ export class Api {
289
289
}
290
290
return false ;
291
291
} ,
292
- isMailOrAcctDisabled : ( e : any ) : boolean => {
292
+ isMailOrAcctDisabled : ( e : unknown ) : boolean => {
293
293
if ( Api . err . isBadReq ( e ) && typeof e . responseText === 'string' ) {
294
294
return e . responseText . indexOf ( 'Mail service not enabled' ) !== - 1 || e . responseText . indexOf ( 'Account has been deleted' ) !== - 1 ;
295
295
}
296
296
return false ;
297
297
} ,
298
- isInsufficientPermission : ( e : any ) : e is AjaxError => e instanceof AjaxError && e . status === 403 && e . responseText . indexOf ( 'insufficientPermissions' ) !== - 1 ,
299
- isNotFound : ( e : any ) : e is AjaxError => e instanceof AjaxError && e . status === 404 ,
300
- isBadReq : ( e : any ) : e is AjaxError => e instanceof AjaxError && e . status === 400 ,
301
- isReqTooLarge : ( e : any ) : e is AjaxError => e instanceof AjaxError && e . status === 413 ,
302
- isServerErr : ( e : any ) : e is AjaxError => e instanceof AjaxError && e . status >= 500 ,
303
- isBlockedByProxy : ( e : any ) : e is AjaxError => {
298
+ isInsufficientPermission : ( e : unknown ) : e is AjaxError => e instanceof AjaxError && e . status === 403 && e . responseText . indexOf ( 'insufficientPermissions' ) !== - 1 ,
299
+ isNotFound : ( e : unknown ) : e is AjaxError => e instanceof AjaxError && e . status === 404 ,
300
+ isBadReq : ( e : unknown ) : e is AjaxError => e instanceof AjaxError && e . status === 400 ,
301
+ isReqTooLarge : ( e : unknown ) : e is AjaxError => e instanceof AjaxError && e . status === 413 ,
302
+ isServerErr : ( e : unknown ) : e is AjaxError => e instanceof AjaxError && e . status >= 500 ,
303
+ isBlockedByProxy : ( e : unknown ) : e is AjaxError => {
304
304
if ( ! ( e instanceof AjaxError ) ) {
305
305
return false ;
306
306
}
@@ -314,11 +314,11 @@ export class Api {
314
314
}
315
315
return false ;
316
316
} ,
317
- isSignificant : ( e : any ) => {
317
+ isSignificant : ( e : unknown ) => {
318
318
return ! Api . err . isNetErr ( e ) && ! Api . err . isServerErr ( e ) && ! Api . err . isNotFound ( e ) && ! Api . err . isMailOrAcctDisabled ( e ) && ! Api . err . isAuthErr ( e )
319
319
&& ! Api . err . isBlockedByProxy ( e ) ;
320
320
} ,
321
- isInPrivateMode : ( e : any ) => {
321
+ isInPrivateMode : ( e : unknown ) => {
322
322
return e instanceof Error && e . message . startsWith ( 'BrowserMsg() (no status text): -1 when GET-ing blob:moz-extension://' ) ;
323
323
}
324
324
} ;
@@ -667,10 +667,10 @@ export class Api {
667
667
}
668
668
669
669
private static internal = {
670
- isStandardError : ( e : any ) : e is StandardError => {
670
+ isStandardError : ( e : unknown ) : e is StandardError => {
671
671
return e && typeof e === 'object' && ( e as StandardError ) . hasOwnProperty ( 'internal' ) && Boolean ( ( e as StandardError ) . message ) ;
672
672
} ,
673
- isRawAjaxError : ( e : any ) : e is RawAjaxError => {
673
+ isRawAjaxError : ( e : unknown ) : e is RawAjaxError => {
674
674
return e && typeof e === 'object' && typeof ( e as RawAjaxError ) . readyState === 'number' ;
675
675
} ,
676
676
apiCall : async ( url : string , path : string , fields : Dict < any > , fmt : ReqFmt , progress ?: ProgressCbs , headers ?: Dict < string > , resFmt : ResFmt = 'json' , method : ReqMethod = 'POST' ) => {
0 commit comments