A San Francisco man arrested this week after federal agents found a crude bomb in a messenger bag in his apartment attempted to buy lethal toxins over the Internet, according to an FBI affidavit unsealed Friday.

The affidavit also revealed that, for more than a year, the U.S. Department of Homeland Security has been investigating a secretive Internet-based marketplace suspected of connecting manufacturers of lethal toxins and other controlled substances with potential buyers.

Ryan Kelly Chamberlain, 42, was arrested Tuesday after federal agents found the makings of an improvised bomb -- explosive powder, a motor, wires for a detonator, ball bearings and screws -- in his Polk Street apartment, according to a criminal complaint affidavit.

The items were found during a search Saturday in a messenger bag allegedly belonging to Chamberlain, according to the complaint affidavit.

If convicted, Chamberlain faces up to 10 years in prison.

Authorities have said they weren’t sure what Chamberlain planned to do with materials found inside his home. But according to a second affidavit unsealed in court Friday, Chamberlain received a package containing possible toxins, such as cyanide and a lethal biological agent known as abrin, shipped from a UPS store in Vacaville last December.