Are AC-DC 5V power supply modules legal in USA if mounted inside an outlet box?
No, because of the source. 

Generally anything you find on eBay or Amazon Marketplace is from the endless junkstream from Alibaba.  These things are firestarters. 

There are two things you need.  

Must have a UL listing (or other recognized testing lab; not CE)

Equipment used in mains wiring must meet basic quality standards.  That is called out on literally the first page of the National Electrical Code, in section 110.2.  

In practical terms, that means approved by Underwriter's Laboratories, or a list of other "Nationally Recognized Testing Labs" seen to be of equal reliability: this list is maintained by OSHA.  These include CSA, ETL, Intertek, BSI, TUV and a few others. 

Notably, the list does NOT include CE, CCC, FCC or ROHS; none of these things are testing labs. These marks are typically used when the Chinese maker can't qualify for an NRTL. They certainly try to make people think CE is a meaningful mark; it's not, except for one context for items shipped from the manufacturer within Europe.  Outside that, the mark is certainly fraudulent.

All this is because the device is interacting with mains voltage, and so has the possibility of starting a fire. 

Must use according to instructions and labeling

This is in the NEC in the next section, at 110.3(b).  The reason is that the testing labs (UL etc.) only test the item for certain uses - those discussed in the instructions and labeling. Using it "off-label" means the item has not been tested for that use. 

A related issue is "electronic components" vs "equipment/devices". Equipment makers have the option of using electronic components that have already been UL-certified, which speeds up certification of the equipment.  UL calls this component certification "RU" - we call this "Really Useless" (thanks ThreePhaseEel) because the component is simply not rated for direct use in building wiring.   And obviously, the labeling and instructions say nothing about using that way.

So your idea of using a module is fine; however you must use a module that is UL-listed for that purpose.