Aims. The aim of this paper is to study deuterated water in the solar-type
protostars NGC1333 IRAS4A and IRAS4B, to compare their HDO abundance
distribution with other star-forming regions, and to constrain their HDO/H2O
ratios. Methods. Using the Herschel/HIFI instrument as well as ground-based
telescopes, we observed several HDO lines covering a large excitation range
(Eup/k=22-168 K) towards these protostars and an outflow position. Non-LTE
radiative transfer codes were then used to determine the HDO abundance profiles
in these sources. Results. The HDO fundamental line profiles show a very broad
component, tracing the molecular outflows, in addition to a narrower emission
component and a narrow absorbing component. In the protostellar envelope of
NGC1333 IRAS4A, the HDO inner (T>100 K) and outer (T<100 K) abundances with
respect to H2 are estimated at 7.5x10^{-9} and 1.2x10^{-11}, respectively,
whereas, in NGC1333 IRAS4B, they are 1.0x10^{-8} and 1.2x10^{-10},
respectively. Similarly to the low-mass protostar IRAS16293-2422, an absorbing
outer layer with an enhanced abundance of deuterated water is required to
reproduce the absorbing components seen in the fundamental lines at 465 and 894
GHz in both sources. This water-rich layer is probably extended enough to
encompass the two sources as well as parts of the outflows. In the outflows
emanating from NGC1333 IRAS4A, the HDO column density is estimated at about
(2-4)x10^{13} cm^{-2}, leading to an abundance of about (0.7-1.9)x10^{-9}. An
HDO/H2O ratio between 7x10^{-4} and 9x10^{-2} is derived in the outflows. In
the warm inner regions of these two sources, we estimate the HDO/H2O ratios at
about 1x10^{-4}-4x10^{-3}. This ratio seems higher (a few %) in the cold
envelope of IRAS4A, whose possible origin is discussed in relation to formation
processes of HDO and H2O.Comment: 16 pages, 13 figure