chore: auth verification (#2867) [skip e2e]
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export type MetaEndpointResponse = {
|
||||
captchaUIUrl: string | null
|
||||
}
|
||||
@@ -26,6 +26,30 @@ export function isErrorResponse<T>(response: HttpResponse<T>): response is HttpE
|
||||
return (response.data as HttpErrorResponseBody)?.error != undefined || response.status >= 400
|
||||
}
|
||||
|
||||
export function getCaptchaHeader<T>(response: HttpResponse<T>) {
|
||||
const captchaHeader = response.headers?.get('x-captcha-required')
|
||||
if (captchaHeader) {
|
||||
return captchaHeader
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function getErrorMessageFromErrorResponseBody(data: HttpErrorResponseBody, defaultMessage?: string): string {
|
||||
let errorMessage = defaultMessage || 'Unknown error'
|
||||
if (
|
||||
data &&
|
||||
typeof data === 'object' &&
|
||||
'error' in data &&
|
||||
data.error &&
|
||||
typeof data.error === 'object' &&
|
||||
'message' in data.error
|
||||
) {
|
||||
errorMessage = data.error.message as string
|
||||
}
|
||||
|
||||
return errorMessage
|
||||
}
|
||||
|
||||
export function getErrorFromErrorResponse(response: HttpErrorResponse): HttpError {
|
||||
const embeddedError = response.data.error
|
||||
if (embeddedError) {
|
||||
|
||||
@@ -13,6 +13,7 @@ export * from './Auth/SignInData'
|
||||
export * from './Auth/SignInResponse'
|
||||
export * from './Auth/SignOutResponse'
|
||||
export * from './Auth/User'
|
||||
export * from './Auth/MetaEndpointResponse'
|
||||
|
||||
/** Temps are awaiting final publish state on server repo */
|
||||
export * from './Temp/SharedVaultMoveType'
|
||||
|
||||
Reference in New Issue
Block a user