fix: safer (and correct) isUnauthorizedError

This commit is contained in:
Divlo 2023-04-02 23:32:28 +02:00
parent 71e0d82655
commit 41a0f1839f
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9

View File

@ -19,7 +19,12 @@ export const isUnauthorizedError = (
error: unknown error: unknown
): error is UnauthorizedError => { ): error is UnauthorizedError => {
return ( return (
error instanceof UnauthorizedError && typeof error === 'object' &&
error != null &&
'data' in error &&
typeof error.data === 'object' &&
error.data != null &&
'type' in error.data &&
error.data.type === 'UnauthorizedError' error.data.type === 'UnauthorizedError'
) )
} }