It has a selfie 'lens': NIRcam has extra optics that can be swung in that allows the camera to focus on the primary mirror instead of out in the great infinity.
So in this sense webb is already a camera which can photograph itself!
This capability exists for mirror alignment: They'll point webb at an isolated star, switch to focusing on the primary mirror, swap in optics that cause small phase differences to result in diffraction patterns, and then they can use the resulting images to fine tune the positioning of the mirror segments to a small fraction of the wavelength of light that they're using.