async def METHOD_NAME(
    backend: BackendApp, websocket: Websocket
) -> Tuple[BaseClientContext | None, dict[str, object] | None]:
    try:
        handshake = ServerHandshake()
        challenge_req = handshake.build_challenge_req()
        await websocket.send(challenge_req)
        # Websocket can return both bytes or utf8-string messages, we only accept the former
        answer_req: Union[bytes, str] = await websocket.receive()
        if not isinstance(answer_req, bytes):
            raise ProtocolError(
                ProtocolErrorFields.BadRequest("Expected bytes message in websocket")
            )
        handshake.process_answer_req(answer_req)
        if handshake.answer_type == HandshakeType.AUTHENTICATED:
            context, result_req, error_infos = await _process_authenticated_answer(
                backend, handshake
            )
        else:
            assert handshake.answer_type == HandshakeType.INVITED
            context, result_req, error_infos = await _process_invited_answer(backend, handshake)
    except ProtocolError as exc:
        context = None
        result_req = handshake.build_bad_protocol_result_req(str(exc))
        error_infos = {"reason": str(exc), "handshake_type": handshake.answer_type}
    await websocket.send(result_req)
    return context, error_infos