Yes, Coca was technically legal under the 1906 U.S. Pure Foods and Drugs Act.
That act did not even mention Coca, and only mentioned cocaine (but neither caffeine or nicotine)in its list of substances that had to be labeled.
Theoretically then, sale of products as Vin Mariani should have continued, whether as a food or drug, though with proportion of cocaine alkaloid clearly labeled.
But it gave the U.S.D.A. the power to ban the sale of what it termed dangerous to the public health substances in foods.
This power required NO justification upon scientific objectivity. The U.S.D.A. was free to simply declare a substance dangerous and or deleterious to human health, with the accompanying charge that a substance had to be restricted because it was 'habit-forming' - a set of concerns belying this Act's MERCANTILIST nature as an extension of the U.S.D.A.'s mission to promote U.S. domestic agriculture, along with the 1906 Act's cute exemption of such, namely Tobacco, from the jurisdiction of this new powers of the USDA- now banned from even regulating Tobacco, yet empowered to declare it potential competitors 'dangerous' and thereby illegal.
Harvey Wiley went after Coca products sold as foods -- primarily beverages -- with prosecutions of manufacturers for 'adulteration' for containing cocaine, under the 'reasoning' that the cocaine alkaloid was dangerous to human health- never mind the lack of any showing for the dilute amounts contained within Coca. This was whether or not the product was so labeled, even for things obviously containing it, as Coffee contains caffeine, clearly labeled as Coca products; because Wiley simply declared cocaine to be so dangerous as to automatically render the product "adulterated.".
Wiley's USDA-AMA-APhA clique went after the use of Coca products as OTC drugs by campaigning with 'model legislation' campaigns to the various State legislatures to get them to make products as Vin Mariani prescription only, that rested upon a negative spin upon bulky herbal based preparations as Vin Mariani as "nostrums" -- after all concentrated pharmaceuticals, pills where more profitable per truckload. And they bragged about it, even as cocaine use shifted towards more concentrated modes available on the black market..
The Coca manufacturers responded by retreating- betraying their righteous stance that Coca was not concentrated cocaine as any sort of substance of abuse, by acting as if they had something to be embarrassed about by cocaine's mere presence- creating a false look that they had something they had to hide.
Vin Mariani followed what Coca Cola did a few years earlier- removing the cocaine alkaloid. This would keep it legal, though neutered, provided it was not sold as a medicine- (Connecticut after 1907 charge of misbranding)
The prescription requirement -- non refillable -- was of course a suicide requirement, like insisting upon a doctor's visit for a cup of coffee.
Wiley would push for laws banning the other major Coca alkaloids, and write the term 'coca leaves' into the new legislation, pushed through 1912 and by 1914 becoming the Harrison Narcotics Act.