Crush tomatoes in a saucepan, removing cores as you work. Add onions and bring to a low boil over medium heat. Reduce heat to a simmer.
Place allspice, cloves, cinnamon, peppercorns, celery seeds, bay leaf, mustard seeds, and garlic in an infuser or tie in a small clean cloth (sachet). Add to simmering tomatoes along with brown sugar, nutmeg, and red pepper flake.
Simmer, uncovered, stirring occasionally, until reduced by about half, 30 minutes.
Add vinegar and simmer an additional 10 minutes.
Remove sachet of spices and transfer to a blender. Blend smooth and add molasses and kosher salt to taste.