As Griffiths says:
Suppose we have a piece of polarized material - that is, an object containing a lot of microscopic dipoles lined up. The dipole moment per unit volume P is given. What is the electric potential produced by this object (not the field that may have caused the polarization, but the field the polarization itself causes)? Well, we know what the field of an individual dipole looks like, so why not to chop the material up the infinitesimal dipoles and integrate to get the total? For a single dipole p
$$ V ({\bf {r}})= { 1 \over 4 \pi \epsilon_0} {\textbf p \cdot \hat r \over r^2 }$$
where $ \vec r$ is the vector from the dipole to the point at which we are evaluating the potential.
In the present context, we have a dipole moment $ \bf p = \bf P \rm d \tau ' $ in each volume element $ \rm d \tau '$, so the total potential (function) is $$ V ({\bf {r}})= {1 \over 4 \pi \epsilon_0} \int_{\tau} { {\bf{P}} ({\bf {r'}}) \cdot \hat r \over r^2} \rm d \tau '$$
After some maths, he shows that:
$$ V ({\bf {r}})= { 1 \over 4 \pi \epsilon_0} \oint_{\partial \tau}{\sigma_p \over r } d \sigma' + { 1 \over 4 \pi \epsilon_0} \int_{ \tau}{\rho_p \over r } d \tau'$$
where the quantities $$ \sigma_p = \bf P \cdot \hat n$$ $$ \rho_p = - \nabla \cdot \bf P $$
are the surface charge and the volume charge densities respectively.
As far as I understood, the last equation is very general (at least for perfect dielectrics) and it can be used to calculate the potential ANYWHERE you want, even INSIDE the dielectric. But the formula we started with is valid only if you are far away from the dipole... so how can we prove the universality of our result even if we used a (strong) condition at the beginning?