It was a pre-emptive strike based on the behaviors of a state sponsor of terrorism. It’s not like the US and its allies have not tried to stop this before - see StuxNet
Sure, but is a kinetic pre-emptive strike in this context legal?
Because this is what underlies all of this -- is the premise that Iran is behaving in an unacceptable and illegal fashion and therefore a legal response with violence is justified.
This all presupposes that Iran is breaking the law with their production of nuclear weapons. Are they breaking the law with their production of nuclear weapons?
What does "legal" even really mean between states at war. The consequences typically come down to a popularity contest and Iran is one of the few states with fewer friends than Israel.
Was Iran's activities funding militias in Lebanon, Syria, Iraq and Yemen, which launched attacks against Israel and US forces "legal"? Which of the US' activities were "legal"? It's all mostly a bad joke.
It's tricky. Arming a country or group than then launches an attack, or uses those weapons in a war, doesn't make you a participant in that conflict. This is why Europe and the US can supply weapons to Ukraine without being participants in a conflict with Russia.
However Iran has the stated intention of destroying the state of Israel, and actively incites it's proxies to attack Israel, and this could be seen as a valid justification for taking action. Not a lawyer though.
Countries can attack others. There is not like a superset of a country over all countries that says what is and isn’t legal. All we have are agreements and treaties.
Not that we would or should but the US could attack any number of countries today and only if one or more countries stopped the US would the victor be able to say it’s illegal.
This is between nation states. Concepts like laws and legality really don’t apply at this level of abstraction. Agreements are a matter of convenience and convention because there is no higher authority that can enforce them.
Geopolitics operates in an explicitly anarchic arena.