In the optics world, when light (assumed as a plane electromagnetic wave having complex wavenumber $k_0$), $$ E = E_0 \cdot e^{i(kx-\omega t)} $$ travels from one medium (e.g. vacuum) into another (denoted by index $M$, e.g. some glass), its wavelength changes from $\lambda_0$ to $\lambda_M$ and it is damped. We describe that using the refractive index $\tilde{n}$ of the medium $M$: $$ \tilde{n} = n + i \kappa $$ The complex wavenumber inside the medium is then $k_M = k_0 \cdot \tilde{n}$. This gives $$ E=E_0 \cdot e^{-\frac{2 \pi}{\lambda_0}\cdot \kappa} \cdot e^{i(\frac{2\pi}{\lambda_M} x - \omega t)} $$ where the first e-function decribes the damping and we see the changed wavelength $\lambda_M$ inside the medium in the second exponent, so in total a damped wave of different wavelength.
The complex refractive index basically consists of the (complex) relative permittivity $\epsilon_r$: $$ \tilde{n} = \sqrt{\epsilon_r \mu_r} \approx \sqrt{\epsilon_r} $$ (for $\mu_r \approx 1$, which I think is true for most dielectric materials at frequencies in the visible spectral range).
Now, in the electromagnetic world, when an E-field enters a medium of permittivity $\epsilon_r$, then the displacement field $D$ is $$ D = \epsilon_0 \epsilon_r E $$ and as discussed in Wikipedia (https://en.wikipedia.org/wiki/Permittivity), the permittivity results in damping and a phase difference between $D$ and $E$, which I guess is the cause for the wavelength change described by the real part of the refractive index in the optics world (please correct me if that's wrong)?
In this equation, the permittivity is just a factor for $E$, while in the optics world, it is in the exponent as part of the refractive index. But both views must be consistent... So how does the permittivity get into the exponent?