Legislation that will dramatically expand the powers of Canada's spy agency has cleared a key hurdle.