file-type-checker
Version:
Detect and validate file types by their signatures (✨magic numbers✨)
186 lines (185 loc) • 6.86 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPCAP = exports.isDOC = exports.isTTF = exports.isSTL = exports.isSQLITE = exports.isRTF = exports.isPS = exports.isPDF = exports.isPARQUET = exports.isORC = exports.isINDD = exports.isMACHO = exports.isEXE = exports.isELF = exports.isBLEND = void 0;
const core_1 = require("../core");
const utils_1 = require("../utils");
/**
* Determine if file content contains a valid 'blend' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'blend' in file content, otherwise false
*/
function isBLEND(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "blend");
}
exports.isBLEND = isBLEND;
/**
* Determine if file content contains a valid 'elf' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'elf' in file content, otherwise false
*/
function isELF(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "elf");
}
exports.isELF = isELF;
/**
* Determine if file content contains a valid 'exe' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'exe' in file content, otherwise false
*/
function isEXE(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "exe");
}
exports.isEXE = isEXE;
/**
* Determine if file content contains a valid 'mach-o' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'mach-o' in file content, otherwise false
*/
function isMACHO(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "macho");
}
exports.isMACHO = isMACHO;
/**
* Determine if file content contains a valid 'indd' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'indd' in file content, otherwise false
*/
function isINDD(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "indd");
}
exports.isINDD = isINDD;
/**
* Determine if file content contains a valid 'orc' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'orc' in file content, otherwise false
*/
function isORC(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "orc");
}
exports.isORC = isORC;
/**
* Determine if file content contains a valid 'parquet' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'parquet' in file content, otherwise false
*/
function isPARQUET(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "parquet");
}
exports.isPARQUET = isPARQUET;
/**
* Determine if file content contains a valid 'pdf' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'pdf' in file content, otherwise false
*/
function isPDF(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "pdf");
}
exports.isPDF = isPDF;
/**
* Determine if file content contains a valid 'ps' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'ps' in file content, otherwise false
*/
function isPS(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "ps");
}
exports.isPS = isPS;
/**
* Determine if file content contains a valid 'rtf' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'rtf' in file content, otherwise false
*/
function isRTF(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "rtf");
}
exports.isRTF = isRTF;
/**
* Determine if file content contains a valid 'sqlite' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'sqlite' in file content, otherwise false
*/
function isSQLITE(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "sqlite");
}
exports.isSQLITE = isSQLITE;
/**
* Determine if file content contains a valid 'stl' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'stl' in file content, otherwise false
*/
function isSTL(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "stl");
}
exports.isSTL = isSTL;
/**
* Determine if file content contains a valid 'ttf' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'ttf' in file content, otherwise false
*/
function isTTF(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "ttf");
}
exports.isTTF = isTTF;
/**
* Determine if file content contains a valid 'doc' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'doc' in file content, otherwise false
*/
function isDOC(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "doc");
}
exports.isDOC = isDOC;
/**
* Determine if file content contains a valid 'pcap' file signature
*
* @param file File content represents in Array<number> / ArrayBuffer / Uint8Array
*
* @returns {boolean} True if found a signature of type 'pcap' in file content, otherwise false
*/
function isPCAP(file) {
const fileChunk = (0, utils_1.getFileChunk)(file);
return core_1.FileTypes.checkByFileType(fileChunk, "pcap");
}
exports.isPCAP = isPCAP;