New Zealand has passed historic legislation that will make it impossible for people born after 2008 to buy cigarettes or tobacco products.