A theory of magnetic flux transfer at the Earth's magnetopause