The Near Infrared Imager and Slitless Spectrograph for the James Webb Space Telescope -- IV. Aperture Masking Interferometry