// @ts-check /** * @typedef {object} MimeSniffPattern * @prop {ArrayLike} bytes The byte pattern to use for MIME sniffing, lifted from the "MIME Sniffing" spec. * @prop {ArrayLike} mask The pattern mask to use for MIME sniffing, lifted from the "MIME Sniffing" spec. */ /** * @typedef {object} SupportedFileType * @prop {string} name The English name of a file type. * @prop {string[]} extensions File extension for this type, with the leading dot. * @prop {string} mimeType MIME type for this file type. * @prop {string} route The route to the file type's page. * @prop {MimeSniffPattern[]} mimeSniffPatterns MIME sniffing patterns. */ /** @type {SupportedFileType[]} */ export const SUPPORTED_FILE_TYPES = [ { name: "GIF", extensions: [".gif", "image/gif"], mimeType: "image/gif", route: "/gif", mimeSniffPatterns: [ { bytes: [0x47, 0x49, 0x46, 0x38, 0x37, 0x61], mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], }, { bytes: [0x47, 0x49, 0x46, 0x38, 0x39, 0x61], mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], }, ], }, { name: "PNG", extensions: [".png", ".apng"], mimeType: "image/png", route: "/png", mimeSniffPatterns: [{ bytes: [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A], mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], }], }, ];