To identify the microscopic mechanism of heavy-fermion Cooper pairing is an unresolved challenge in quantum matter studies; it may also relate closely to finding the pairing mechanism of high temperature superconductivity. Magnetically mediated Cooper pairing has long been the conjectured basis of heavy-fermion superconductivity but no direct verification of this hypothesis was achievable. Here, we use a novel approach based on precision measurements of the heavy-fermion band structure using quasiparticle interference (QPI) imaging, to reveal quantitatively the momentum-space (k-space) structure of the f-electron magnetic interactions of CeCoIn5. Then, by solving the superconducting gap equations on the two heavy-fermion bands $E_k^{alpha,beta}$ with these magnetic interactions as mediators of the Cooper pairing, we derive a series of quantitative predictions about the superconductive state. The agreement found between these diverse predictions and the measured characteristics of superconducting CeCoIn5, then provides direct evidence that the heavy-fermion Cooper pairing is indeed mediated by the f-electron magnetism.