Countries have worked through the night to broker a deal on climate finance at the UN climate summit as negotiations stretched into overtime.