The measure was included in a foreign aid package providing support to Ukraine and Israel. TikTok has vowed to challenge the law in federal court.