Context. Whether or not magnetic fields play a key role in dynamically shaping the products of the star formation process is still largely debated. For example, in magnetized protostellar formation models, magnetic braking plays a major role in the regulation of the angular momentum transported from large envelope scales to the inner envelope, and is expected to be responsible for the resulting protostellar disk sizes. However, non-ideal magnetohydrodynamic effects that rule the coupling of the magnetic field to the gas also depend heavily on the local physical conditions, such as the ionization fraction of the gas. Aims. The purpose of this work is to observationally characterize the level of ionization of the gas at small envelope radii and to investigate its relation to the efficiency of the coupling between the star-forming gas and the magnetic field in the Class 0 protostar B335. Methods. We obtained molecular line emission maps of B335 with ALMA, which we use to measure the deuteration fraction of the gas, R D , its ionization fraction, χ e , and the cosmic-ray ionization rate, ζ CR , at envelope radii ≲1000 au. Results. We find large fractions of ionized gas, χ e ≃ 1 − 8 × 10 −6 . Our observations also reveal an enhanced ionization that increases at small envelope radii, reaching values up to ζ CR ≃ 10 −14 s −1 at a few hundred astronomical units (au) from the central protostellar object. We show that this extreme ζ CR can be attributed to the presence of cosmic rays accelerated close to the protostar. Conclusions. We report the first resolved map of ζ CR at scales ≲ 1000 au in a solar-type Class 0 protostar, finding remarkably high values. Our observations suggest that local acceleration of cosmic rays, and not the penetration of interstellar Galactic cosmic rays, may be responsible for the gas ionization in the inner envelope, potentially down to disk-forming scales. If confirmed, our findings imply that protostellar disk properties may also be determined by local processes that set the coupling between the gas and the magnetic field, and not only by the amount of angular momentum available at large envelope scales and the magnetic field strength in protostellar cores. We stress that the gas ionization we find in B335 significantly stands out from the typical values routinely used in state-of-the-art models of protostellar formation and evolution. If the local processes of ionization uncovered in B335 are prototypical to low-mass protostars, our results call for a revision of the treatment of ionizing processes in magnetized models for star and disk formation.