Bruni, Ludovico, Papal secretary