Foam is water repellant but as Thiggy says, should not be left exposed. Also, there are different products with different expansion rates. Use low expansion types for windows and doors that could be deformed by the foam. Leave the high expansion foam for wall voids and penetrations that are less accessible and unlikely to be damaged by rapidly expanding foam volume.