The Spanish parliament has approved a controversial amnesty law that paves the way for hundreds of people facing prosecution for their roles in the failed independence bid in Catalonia to be pardoned.