On Saturday, as US officials and their foreign allies scrambled to understand how dozens of classified intelligence documents had ended up on the internet, they were stunned — and occasionally infuriated — at the extraordinary range of detail the files exposed about how the United States spies on friends and foes alike.