sigcheck 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1081 -0
  3. package/dist/core/file-types/audio.d.ts +12 -0
  4. package/dist/core/file-types/audio.js +93 -0
  5. package/dist/core/file-types/compressed.d.ts +10 -0
  6. package/dist/core/file-types/compressed.js +155 -0
  7. package/dist/core/file-types/image.d.ts +22 -0
  8. package/dist/core/file-types/image.js +248 -0
  9. package/dist/core/file-types/index.d.ts +109 -0
  10. package/dist/core/file-types/index.js +215 -0
  11. package/dist/core/file-types/other.d.ts +21 -0
  12. package/dist/core/file-types/other.js +234 -0
  13. package/dist/core/file-types/video.d.ts +15 -0
  14. package/dist/core/file-types/video.js +153 -0
  15. package/dist/core/index.d.ts +3 -0
  16. package/dist/core/index.js +19 -0
  17. package/dist/core/interfaces/dto/detected-file-info.d.ts +10 -0
  18. package/dist/core/interfaces/dto/detected-file-info.js +2 -0
  19. package/dist/core/interfaces/dto/index.d.ts +1 -0
  20. package/dist/core/interfaces/dto/index.js +17 -0
  21. package/dist/core/interfaces/index.d.ts +2 -0
  22. package/dist/core/interfaces/index.js +18 -0
  23. package/dist/core/interfaces/options/detect-file-options.d.ts +6 -0
  24. package/dist/core/interfaces/options/detect-file-options.js +2 -0
  25. package/dist/core/interfaces/options/file-validator-options.d.ts +6 -0
  26. package/dist/core/interfaces/options/file-validator-options.js +2 -0
  27. package/dist/core/interfaces/options/index.d.ts +4 -0
  28. package/dist/core/interfaces/options/index.js +20 -0
  29. package/dist/core/interfaces/options/validate-file-type-options.d.ts +7 -0
  30. package/dist/core/interfaces/options/validate-file-type-options.js +2 -0
  31. package/dist/core/interfaces/options/zip-validator-options.d.ts +6 -0
  32. package/dist/core/interfaces/options/zip-validator-options.js +2 -0
  33. package/dist/core/types/file-info.d.ts +10 -0
  34. package/dist/core/types/file-info.js +2 -0
  35. package/dist/core/types/file-signature.d.ts +10 -0
  36. package/dist/core/types/file-signature.js +2 -0
  37. package/dist/core/types/index.d.ts +2 -0
  38. package/dist/core/types/index.js +18 -0
  39. package/dist/detection/index.d.ts +10 -0
  40. package/dist/detection/index.js +54 -0
  41. package/dist/index.d.ts +55 -0
  42. package/dist/index.js +28 -0
  43. package/dist/utils/index.d.ts +67 -0
  44. package/dist/utils/index.js +167 -0
  45. package/dist/validation/audio.d.ts +50 -0
  46. package/dist/validation/audio.js +84 -0
  47. package/dist/validation/compressed.d.ts +34 -0
  48. package/dist/validation/compressed.js +54 -0
  49. package/dist/validation/image.d.ts +128 -0
  50. package/dist/validation/image.js +225 -0
  51. package/dist/validation/index.d.ts +16 -0
  52. package/dist/validation/index.js +91 -0
  53. package/dist/validation/other.d.ts +120 -0
  54. package/dist/validation/other.js +185 -0
  55. package/dist/validation/video.d.ts +78 -0
  56. package/dist/validation/video.js +140 -0
  57. package/package.json +97 -0
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileTypes = exports.FILE_TYPES_REQUIRED_ADDITIONAL_CHECK = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const audio_1 = require("./audio");
6
+ const compressed_1 = require("./compressed");
7
+ const other_1 = require("./other");
8
+ const image_1 = require("./image");
9
+ const video_1 = require("./video");
10
+ const validation_1 = require("../../validation");
11
+ exports.FILE_TYPES_REQUIRED_ADDITIONAL_CHECK = [
12
+ "m4v",
13
+ "flv",
14
+ "mp4",
15
+ "mkv",
16
+ "webm",
17
+ "avif",
18
+ "heic",
19
+ ];
20
+ /**
21
+ * A class hold all supported file typs with their unique signatures
22
+ */
23
+ class FileTypes {
24
+ /**
25
+ * Receive information on a file type by its property name from FileTypes class
26
+ *
27
+ * @param propertyName Property name from FileTypes class
28
+ *
29
+ * @returns {FileInfo} File type information
30
+ */
31
+ static getInfoByName(propertyName) {
32
+ const file = (0, utils_1.fetchFromObject)(FileTypes, propertyName.toUpperCase());
33
+ return file;
34
+ }
35
+ /**
36
+ * Receive an array of file type signatures by its property name from FileTypes class
37
+ *
38
+ * @param propertyName Property name from FileTypes class
39
+ *
40
+ * @returns {Array<FileSignature>} All unique signatures with their information
41
+ */
42
+ static getSignaturesByName(propertyName) {
43
+ const { signatures } = (0, utils_1.fetchFromObject)(FileTypes, propertyName.toUpperCase());
44
+ return signatures;
45
+ }
46
+ /**
47
+ * Determine if a valid signature exist in a file chunk
48
+ *
49
+ * @param fileChunk A chunk from the beginning of a file content, represents in array of numbers
50
+ * @param acceptedSignatures Valid signatures to search for in fileChunk
51
+ *
52
+ * @returns {boolean} True if found a valid signature inside the chunk, otherwise false
53
+ */
54
+ static detectSignature(fileChunk, acceptedSignatures) {
55
+ for (const signature of acceptedSignatures) {
56
+ let found = true;
57
+ const offset = signature.offset || 0;
58
+ let skippedBytes = 0;
59
+ for (let i = 0; i < signature.sequence.length; i++) {
60
+ if (signature.skippedBytes && signature.skippedBytes.includes(i)) {
61
+ skippedBytes++;
62
+ continue;
63
+ }
64
+ if (fileChunk[offset + i] !== signature.sequence[i - skippedBytes]) {
65
+ found = false;
66
+ break;
67
+ }
68
+ }
69
+ if (found) {
70
+ return signature;
71
+ }
72
+ }
73
+ return undefined;
74
+ }
75
+ /**
76
+ * Perfomrs an additional check for detected file types by their unique structure
77
+ *
78
+ * @param fileChunk A chunk from the beginning of a file content, represents in array of numbers
79
+ * @param detectedFiles A list of detected files
80
+ * @returns {string | undefined} File type extension if found, otherwise undefined
81
+ */
82
+ static detectTypeByAdditionalCheck(fileChunk, detectedFiles) {
83
+ const detectedExtensions = detectedFiles.map((df) => df.extension);
84
+ if (detectedExtensions.some((de) => ["m4v", "flv", "mp4", "heic"].includes(de))) {
85
+ if (detectedExtensions.includes("heic") && (0, validation_1.isHEIC)(fileChunk))
86
+ return "heic";
87
+ const isFlv = (0, validation_1.isFLV)(fileChunk);
88
+ if (isFlv)
89
+ return "flv";
90
+ const isM4v = (0, validation_1.isM4V)(fileChunk) && !(0, validation_1.isHEIC)(fileChunk);
91
+ if (isM4v)
92
+ return "m4v";
93
+ return "mp4";
94
+ }
95
+ else if (detectedExtensions.some((de) => ["mkv", "webm"].includes(de))) {
96
+ const matroskaDocTypeElement = (0, utils_1.findMatroskaDocTypeElements)(fileChunk);
97
+ if (matroskaDocTypeElement === "mkv" && (0, validation_1.isMKV)(fileChunk))
98
+ return "mkv";
99
+ else if (matroskaDocTypeElement === "webm" && (0, validation_1.isWEBM)(fileChunk))
100
+ return "webm";
101
+ return undefined;
102
+ }
103
+ else if (detectedExtensions.some((de) => ["avif"].includes(de))) {
104
+ const isAvif = (0, utils_1.isAvifStringIncluded)(fileChunk);
105
+ if (isAvif)
106
+ return "avif";
107
+ }
108
+ return undefined;
109
+ }
110
+ /**
111
+ * Determine if a file chunk contains a valid signature and return the file signature if exist
112
+ *
113
+ * @param fileChunk A chunk from the beginning of a file content, represents in array of numbers
114
+ * @param acceptedSignatures Valid signatures to search for in fileChunk
115
+ *
116
+ * @returns {FileSignature | undefined } FileSignature if found a valid signature, otherwise undefined
117
+ */
118
+ static detectbBySignatures(fileChunk, acceptedSignatures) {
119
+ for (const signature of acceptedSignatures) {
120
+ let skippedBytes = 0;
121
+ let found = true;
122
+ const offset = signature.offset || 0;
123
+ const signatureLength = (signature === null || signature === void 0 ? void 0 : signature.skippedBytes)
124
+ ? signature.sequence.length + signature.skippedBytes.length
125
+ : signature.sequence.length;
126
+ for (let i = 0; i < signatureLength; i++) {
127
+ if (signature.skippedBytes && signature.skippedBytes.includes(i)) {
128
+ skippedBytes++;
129
+ continue;
130
+ }
131
+ if (fileChunk[offset + i] !== signature.sequence[i - skippedBytes]) {
132
+ found = false;
133
+ break;
134
+ }
135
+ }
136
+ if (found) {
137
+ return signature;
138
+ }
139
+ }
140
+ return undefined;
141
+ }
142
+ /**
143
+ * Determine if file content contains a valid signature of a required type
144
+ *
145
+ * @param fileChunk A chunk from the beginning of a file content, represents in array of numbers
146
+ * @param type The file type to match against
147
+ *
148
+ * @returns {boolean} True if found a signature of the type in file content, otherwise false
149
+ */
150
+ static checkByFileType(fileChunk, type) {
151
+ if (Object.prototype.hasOwnProperty.call(FileTypes, type.toUpperCase())) {
152
+ const acceptedSignatures = FileTypes.getSignaturesByName(type.toUpperCase());
153
+ const detectedSignature = FileTypes.detectSignature(fileChunk, acceptedSignatures);
154
+ if (detectedSignature)
155
+ return true;
156
+ }
157
+ return false;
158
+ }
159
+ }
160
+ exports.FileTypes = FileTypes;
161
+ // audio
162
+ FileTypes.AAC = audio_1.AudioTypes.AAC;
163
+ FileTypes.AMR = audio_1.AudioTypes.AMR;
164
+ FileTypes.FLAC = audio_1.AudioTypes.FLAC;
165
+ FileTypes.M4A = audio_1.AudioTypes.M4A;
166
+ FileTypes.MP3 = audio_1.AudioTypes.MP3;
167
+ FileTypes.WAV = audio_1.AudioTypes.WAV;
168
+ // image
169
+ FileTypes.AVIF = image_1.ImageTypes.AVIF;
170
+ FileTypes.BMP = image_1.ImageTypes.BMP;
171
+ FileTypes.BPG = image_1.ImageTypes.BPG;
172
+ FileTypes.CR2 = image_1.ImageTypes.CR2;
173
+ FileTypes.EXR = image_1.ImageTypes.EXR;
174
+ FileTypes.GIF = image_1.ImageTypes.GIF;
175
+ FileTypes.HEIC = image_1.ImageTypes.HEIC;
176
+ FileTypes.ICO = image_1.ImageTypes.ICO;
177
+ FileTypes.JPEG = image_1.ImageTypes.JPEG;
178
+ FileTypes.PBM = image_1.ImageTypes.PBM;
179
+ FileTypes.PGM = image_1.ImageTypes.PGM;
180
+ FileTypes.PNG = image_1.ImageTypes.PNG;
181
+ FileTypes.PPM = image_1.ImageTypes.PPM;
182
+ FileTypes.PSD = image_1.ImageTypes.PSD;
183
+ FileTypes.TIFF = image_1.ImageTypes.TIFF;
184
+ FileTypes.WEBP = image_1.ImageTypes.WEBP;
185
+ // video
186
+ FileTypes.AVI = video_1.VideoTypes.AVI;
187
+ FileTypes.FLV = video_1.VideoTypes.FLV;
188
+ FileTypes.M4V = video_1.VideoTypes.M4V;
189
+ FileTypes.MKV = video_1.VideoTypes.MKV;
190
+ FileTypes.MOV = video_1.VideoTypes.MOV;
191
+ FileTypes.MP4 = video_1.VideoTypes.MP4;
192
+ FileTypes.OGG = video_1.VideoTypes.OGG;
193
+ FileTypes.SWF = video_1.VideoTypes.SWF;
194
+ FileTypes.WEBM = video_1.VideoTypes.WEBM;
195
+ // compressed
196
+ FileTypes._7Z = compressed_1.CompressedTypes._7Z;
197
+ FileTypes.LZH = compressed_1.CompressedTypes.LZH;
198
+ FileTypes.RAR = compressed_1.CompressedTypes.RAR;
199
+ FileTypes.ZIP = compressed_1.CompressedTypes.ZIP;
200
+ // other
201
+ FileTypes.BLEND = other_1.OtherTypes.BLEND;
202
+ FileTypes.DOC = other_1.OtherTypes.DOC;
203
+ FileTypes.ELF = other_1.OtherTypes.ELF;
204
+ FileTypes.EXE = other_1.OtherTypes.EXE;
205
+ FileTypes.INDD = other_1.OtherTypes.INDD;
206
+ FileTypes.MACHO = other_1.OtherTypes.MACHO;
207
+ FileTypes.ORC = other_1.OtherTypes.ORC;
208
+ FileTypes.PARQUET = other_1.OtherTypes.PARQUET;
209
+ FileTypes.PCAP = other_1.OtherTypes.PCAP;
210
+ FileTypes.PDF = other_1.OtherTypes.PDF;
211
+ FileTypes.PS = other_1.OtherTypes.PS;
212
+ FileTypes.RTF = other_1.OtherTypes.RTF;
213
+ FileTypes.SQLITE = other_1.OtherTypes.SQLITE;
214
+ FileTypes.STL = other_1.OtherTypes.STL;
215
+ FileTypes.TTF = other_1.OtherTypes.TTF;
@@ -0,0 +1,21 @@
1
+ import { FileInfo } from "../types/file-info";
2
+ /**
3
+ * Other files information with their unique signatures
4
+ */
5
+ export declare class OtherTypes {
6
+ static BLEND: FileInfo;
7
+ static DOC: FileInfo;
8
+ static ELF: FileInfo;
9
+ static EXE: FileInfo;
10
+ static INDD: FileInfo;
11
+ static MACHO: FileInfo;
12
+ static PDF: FileInfo;
13
+ static ORC: FileInfo;
14
+ static PARQUET: FileInfo;
15
+ static PS: FileInfo;
16
+ static RTF: FileInfo;
17
+ static SQLITE: FileInfo;
18
+ static STL: FileInfo;
19
+ static TTF: FileInfo;
20
+ static PCAP: FileInfo;
21
+ }
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OtherTypes = void 0;
4
+ /**
5
+ * Other files information with their unique signatures
6
+ */
7
+ class OtherTypes {
8
+ }
9
+ exports.OtherTypes = OtherTypes;
10
+ OtherTypes.BLEND = {
11
+ extension: "blend",
12
+ mimeType: "application/x-blender",
13
+ description: "Blender File Format",
14
+ signatures: [
15
+ {
16
+ sequence: [0x42, 0x4c, 0x45, 0x4e, 0x44, 0x45, 0x52],
17
+ },
18
+ ],
19
+ };
20
+ OtherTypes.DOC = {
21
+ extension: "doc",
22
+ mimeType: "application/msword",
23
+ description: "Old Microsoft Word documents",
24
+ signatures: [
25
+ {
26
+ sequence: [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1],
27
+ compatibleExtensions: [
28
+ "xls",
29
+ "ppt",
30
+ "msi",
31
+ "msg",
32
+ "dot",
33
+ "pps",
34
+ "xla",
35
+ "wiz",
36
+ ],
37
+ description: "An Object Linking and Embedding (OLE) Compound File (CF) (i.e., OLECF) file format, known as Compound Binary File format by Microsoft, used by Microsoft Office 97-2003 applications",
38
+ },
39
+ {
40
+ sequence: [0xdb, 0xa5, 0x2d, 0x00],
41
+ description: "Microsoft Word 2.0 file format",
42
+ },
43
+ ],
44
+ };
45
+ OtherTypes.ELF = {
46
+ extension: "elf",
47
+ mimeType: "application/x-executable",
48
+ description: "Executable and Linking Format executable file (Linux/Unix)",
49
+ signatures: [
50
+ {
51
+ sequence: [0x7f, 0x45, 0x4c, 0x46],
52
+ },
53
+ ],
54
+ };
55
+ OtherTypes.EXE = {
56
+ extension: "exe",
57
+ mimeType: "application/x-msdownload",
58
+ description: "Windows/DOS executable file and its descendants",
59
+ signatures: [
60
+ {
61
+ sequence: [0x4d, 0x5a],
62
+ compatibleExtensions: [
63
+ "acm",
64
+ "ax",
65
+ "cpl",
66
+ "com",
67
+ "dll",
68
+ "drv",
69
+ "efi",
70
+ "fon",
71
+ "iec",
72
+ "ime",
73
+ "mui",
74
+ "ocx",
75
+ "olb",
76
+ "pif",
77
+ "qts",
78
+ "qtx",
79
+ "rs",
80
+ "sys",
81
+ "scr",
82
+ "tsp",
83
+ "vbx",
84
+ "vxd",
85
+ ],
86
+ },
87
+ {
88
+ sequence: [0x5a, 0x4d],
89
+ description: "DOS ZM executable (rare)",
90
+ },
91
+ ],
92
+ };
93
+ OtherTypes.INDD = {
94
+ extension: "indd",
95
+ mimeType: "application/x-indesign",
96
+ description: "Adobe InDesign document",
97
+ signatures: [
98
+ {
99
+ sequence: [
100
+ 0x06, 0x06, 0xed, 0xf5, 0xd8, 0x1d, 0x46, 0xe5, 0xbd, 0x31, 0xef,
101
+ 0xe7, 0xfe, 0x74, 0xb7, 0x1d,
102
+ ],
103
+ compatibleExtensions: ["indt"],
104
+ },
105
+ ],
106
+ };
107
+ OtherTypes.MACHO = {
108
+ extension: "macho",
109
+ mimeType: "application/x-mach-binary",
110
+ description: "Apple OS X ABI Mach-O binary file",
111
+ signatures: [
112
+ {
113
+ sequence: [0xfe, 0xed, 0xfa, 0xce],
114
+ description: "32-bit",
115
+ },
116
+ {
117
+ sequence: [0xce, 0xfa, 0xed, 0xfe],
118
+ description: "32-bit, where target system has reverse byte ordering from host running compiler",
119
+ },
120
+ {
121
+ sequence: [0xfe, 0xed, 0xfa, 0xcf],
122
+ description: "64-bit",
123
+ },
124
+ {
125
+ sequence: [0xcf, 0xfa, 0xed, 0xfe],
126
+ description: "64-bit, where target system has reverse byte ordering from host running compiler",
127
+ },
128
+ {
129
+ sequence: [0xca, 0xfe, 0xba, 0xbe],
130
+ description: "Mach-O Fat Binary",
131
+ },
132
+ ],
133
+ };
134
+ OtherTypes.PDF = {
135
+ extension: "pdf",
136
+ mimeType: "application/pdf",
137
+ description: "Portable Document Format",
138
+ signatures: [
139
+ {
140
+ sequence: [0x25, 0x50, 0x44, 0x46, 0x2d],
141
+ },
142
+ ],
143
+ };
144
+ OtherTypes.ORC = {
145
+ extension: "orc",
146
+ mimeType: "application/x-orc",
147
+ description: "Apache ORC (Optimized Row Columnar) file format for columnar storage",
148
+ signatures: [
149
+ {
150
+ sequence: [0x4f, 0x52, 0x43],
151
+ },
152
+ ],
153
+ };
154
+ OtherTypes.PARQUET = {
155
+ extension: "parquet",
156
+ mimeType: "application/vnd.apache.parquet",
157
+ description: "Apache Parquet file format for columnar storage",
158
+ signatures: [
159
+ {
160
+ sequence: [0x50, 0x41, 0x52, 0x31],
161
+ },
162
+ ],
163
+ };
164
+ OtherTypes.PS = {
165
+ extension: "ps",
166
+ mimeType: "application/postscript",
167
+ description: "PostScript document",
168
+ signatures: [
169
+ {
170
+ sequence: [0x25, 0x21, 0x50, 0x53],
171
+ },
172
+ ],
173
+ };
174
+ OtherTypes.RTF = {
175
+ extension: "rtf",
176
+ mimeType: "application/rtf",
177
+ description: "Rich Text Format word processing file",
178
+ signatures: [
179
+ {
180
+ sequence: [0x7b, 0x5c, 0x72, 0x74, 0x66, 0x31],
181
+ },
182
+ ],
183
+ };
184
+ OtherTypes.SQLITE = {
185
+ extension: "sqlite",
186
+ mimeType: "application/x-sqlite3",
187
+ description: "SQLite database file",
188
+ signatures: [
189
+ {
190
+ sequence: [
191
+ 0x53, 0x51, 0x4c, 0x69, 0x74, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x6d,
192
+ 0x61, 0x74, 0x20, 0x33, 0x00,
193
+ ],
194
+ },
195
+ ],
196
+ };
197
+ OtherTypes.STL = {
198
+ extension: "stl",
199
+ mimeType: "application/sla",
200
+ description: "ASCII STL (STereoLithography) file for 3D printing",
201
+ signatures: [
202
+ {
203
+ sequence: [0x73, 0x6f, 0x6c, 0x69, 0x64],
204
+ },
205
+ ],
206
+ };
207
+ OtherTypes.TTF = {
208
+ extension: "ttf",
209
+ mimeType: "application/x-font-ttf",
210
+ description: "TrueType font file",
211
+ signatures: [
212
+ {
213
+ sequence: [0x74, 0x72, 0x75, 0x65, 0x00],
214
+ },
215
+ {
216
+ sequence: [0x00, 0x01, 0x00, 0x00, 0x00],
217
+ compatibleExtensions: ["tte, dfont"],
218
+ },
219
+ ],
220
+ };
221
+ OtherTypes.PCAP = {
222
+ extension: "pcap",
223
+ mimeType: "application/vnd.tcpdump.pcap",
224
+ description: "Libpcap File Format",
225
+ signatures: [
226
+ {
227
+ sequence: [0xd4, 0xc3, 0xb2, 0xa1],
228
+ },
229
+ {
230
+ sequence: [0x4d, 0x3c, 0xb2, 0xa1],
231
+ description: "Nanosecond resolution",
232
+ },
233
+ ],
234
+ };
@@ -0,0 +1,15 @@
1
+ import { FileInfo } from "../types/file-info";
2
+ /**
3
+ * Video files information with their unique signatures
4
+ */
5
+ export declare class VideoTypes {
6
+ static AVI: FileInfo;
7
+ static FLV: FileInfo;
8
+ static M4V: FileInfo;
9
+ static MKV: FileInfo;
10
+ static MOV: FileInfo;
11
+ static MP4: FileInfo;
12
+ static OGG: FileInfo;
13
+ static SWF: FileInfo;
14
+ static WEBM: FileInfo;
15
+ }
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoTypes = void 0;
4
+ /**
5
+ * Video files information with their unique signatures
6
+ */
7
+ class VideoTypes {
8
+ }
9
+ exports.VideoTypes = VideoTypes;
10
+ VideoTypes.AVI = {
11
+ extension: "avi",
12
+ mimeType: "video/x-msvideo",
13
+ description: "Audio Video Interleave video format",
14
+ signatures: [
15
+ {
16
+ sequence: [
17
+ 0x52, 0x49, 0x46, 0x46, 0x41, 0x56, 0x49, 0x20, 0x4c, 0x49, 0x53,
18
+ 0x54,
19
+ ],
20
+ skippedBytes: [4, 5, 6, 7],
21
+ },
22
+ ],
23
+ };
24
+ VideoTypes.FLV = {
25
+ extension: "flv",
26
+ mimeType: "video/x-flv",
27
+ description: "Flash Video file",
28
+ signatures: [
29
+ {
30
+ sequence: [0x46, 0x4c, 0x56, 0x01],
31
+ },
32
+ {
33
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x4d, 0x34, 0x56, 0x20],
34
+ description: "ISO Media, MPEG v4 system, or iTunes AVC-LC file",
35
+ offset: 4,
36
+ compatibleExtensions: ["mp4", "m4v"],
37
+ },
38
+ ],
39
+ };
40
+ VideoTypes.M4V = {
41
+ extension: "m4v",
42
+ mimeType: "video/x-m4v",
43
+ description: "Apple's video container format, very similar to MP4",
44
+ signatures: [
45
+ {
46
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, 0x32],
47
+ description: "MPEG-4 video | QuickTime file",
48
+ offset: 4,
49
+ compatibleExtensions: ["mp4"],
50
+ },
51
+ {
52
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x4d, 0x34, 0x56, 0x20],
53
+ description: "ISO Media, MPEG v4 system, or iTunes AVC-LC file",
54
+ offset: 4,
55
+ compatibleExtensions: ["mp4", "flv"],
56
+ },
57
+ ],
58
+ };
59
+ VideoTypes.MKV = {
60
+ extension: "mkv",
61
+ mimeType: "video/x-matroska",
62
+ description: "MKV (Matroska Video) is a flexible, open-source media container format that supports multiple audio, video, and subtitle streams in a single file",
63
+ signatures: [
64
+ {
65
+ sequence: [0x1a, 0x45, 0xdf, 0xa3],
66
+ description: "EBML identifier",
67
+ compatibleExtensions: ["webm", "mka", "mks", "mk3d"],
68
+ },
69
+ ],
70
+ };
71
+ VideoTypes.MOV = {
72
+ extension: "mov",
73
+ mimeType: "video/quicktime",
74
+ description: "QuickTime movie file",
75
+ signatures: [
76
+ {
77
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20],
78
+ offset: 4,
79
+ },
80
+ {
81
+ sequence: [0x6d, 0x6f, 0x6f, 0x76],
82
+ offset: 4,
83
+ },
84
+ ],
85
+ };
86
+ VideoTypes.MP4 = {
87
+ extension: "mp4",
88
+ mimeType: "video/mp4",
89
+ description: "A multimedia container format widely used for storing audio, video, and other data, and is known for its high compression efficiency and compatibility with many devices",
90
+ signatures: [
91
+ {
92
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x4d, 0x53, 0x4e, 0x56],
93
+ description: "MPEG-4 video file",
94
+ offset: 4,
95
+ },
96
+ {
97
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6f, 0x6d],
98
+ description: "ISO Base Media file (MPEG-4) v1",
99
+ offset: 4,
100
+ },
101
+ {
102
+ sequence: [0x66, 0x74, 0x79, 0x70, 0x4d, 0x34, 0x56, 0x20],
103
+ description: "ISO Media, MPEG v4 system, or iTunes AVC-LC file",
104
+ offset: 4,
105
+ compatibleExtensions: ["m4v", "flv"],
106
+ },
107
+ ],
108
+ };
109
+ VideoTypes.OGG = {
110
+ extension: "ogg",
111
+ mimeType: "video/ogg",
112
+ description: "Ogg Vorbis Codec compressed Multimedia file",
113
+ signatures: [
114
+ {
115
+ sequence: [
116
+ 0x4f, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
117
+ 0x00, 0x00, 0x00,
118
+ ],
119
+ compatibleExtensions: ["oga", "ogv", "ogx"],
120
+ },
121
+ ],
122
+ };
123
+ VideoTypes.SWF = {
124
+ extension: "swf",
125
+ mimeType: "application/x-shockwave-flash",
126
+ description: "SWF (Shockwave Flash) is a file format for multimedia, vector graphics, and ActionScript, used for creating and delivering animations, games, and other interactive web-based content",
127
+ signatures: [
128
+ {
129
+ sequence: [0x43, 0x57, 0x53],
130
+ description: "Macromedia Shockwave Flash player file (zlib compressed, SWF 6 and later)",
131
+ },
132
+ {
133
+ sequence: [0x46, 0x57, 0x53],
134
+ description: "Macromedia Shockwave Flash player file (uncompressed)",
135
+ },
136
+ {
137
+ sequence: [0x5a, 0x57, 0x53],
138
+ description: "Macromedia Shockwave Flash player file (uncompressed)",
139
+ },
140
+ ],
141
+ };
142
+ VideoTypes.WEBM = {
143
+ extension: "webm",
144
+ mimeType: "video/webm",
145
+ description: "WebM is a royalty-free, open-source media file format optimized for web delivery, using efficient VP8 video and Vorbis audio codecs",
146
+ signatures: [
147
+ {
148
+ sequence: [0x1a, 0x45, 0xdf, 0xa3],
149
+ description: "EBML identifier",
150
+ compatibleExtensions: ["mkv"],
151
+ },
152
+ ],
153
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./file-types";
2
+ export * from "./interfaces";
3
+ export * from "./types";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./file-types"), exports);
18
+ __exportStar(require("./interfaces"), exports);
19
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,10 @@
1
+ import { FileSignature } from "../../types";
2
+ /**
3
+ * Information about a detected file based on its signature
4
+ */
5
+ export interface DetectedFileInfo {
6
+ extension: string;
7
+ mimeType: string;
8
+ description: string;
9
+ signature: FileSignature;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./detected-file-info";