@depup/file-type 21.3.0-depup.0

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.
package/supported.js ADDED
@@ -0,0 +1,360 @@
1
+ export const extensions = [
2
+ 'jpg',
3
+ 'png',
4
+ 'apng',
5
+ 'gif',
6
+ 'webp',
7
+ 'flif',
8
+ 'xcf',
9
+ 'cr2',
10
+ 'cr3',
11
+ 'orf',
12
+ 'arw',
13
+ 'dng',
14
+ 'nef',
15
+ 'rw2',
16
+ 'raf',
17
+ 'tif',
18
+ 'bmp',
19
+ 'icns',
20
+ 'jxr',
21
+ 'psd',
22
+ 'indd',
23
+ 'zip',
24
+ 'tar',
25
+ 'rar',
26
+ 'gz',
27
+ 'bz2',
28
+ '7z',
29
+ 'dmg',
30
+ 'mp4',
31
+ 'mid',
32
+ 'mkv',
33
+ 'webm',
34
+ 'mov',
35
+ 'avi',
36
+ 'mpg',
37
+ 'mp2',
38
+ 'mp3',
39
+ 'm4a',
40
+ 'oga',
41
+ 'ogg',
42
+ 'ogv',
43
+ 'opus',
44
+ 'flac',
45
+ 'wav',
46
+ 'spx',
47
+ 'amr',
48
+ 'pdf',
49
+ 'epub',
50
+ 'elf',
51
+ 'macho',
52
+ 'exe',
53
+ 'swf',
54
+ 'rtf',
55
+ 'wasm',
56
+ 'woff',
57
+ 'woff2',
58
+ 'eot',
59
+ 'ttf',
60
+ 'otf',
61
+ 'ttc',
62
+ 'ico',
63
+ 'flv',
64
+ 'ps',
65
+ 'xz',
66
+ 'sqlite',
67
+ 'nes',
68
+ 'crx',
69
+ 'xpi',
70
+ 'cab',
71
+ 'deb',
72
+ 'ar',
73
+ 'rpm',
74
+ 'Z',
75
+ 'lz',
76
+ 'cfb',
77
+ 'mxf',
78
+ 'mts',
79
+ 'blend',
80
+ 'bpg',
81
+ 'docx',
82
+ 'pptx',
83
+ 'xlsx',
84
+ '3gp',
85
+ '3g2',
86
+ 'j2c',
87
+ 'jp2',
88
+ 'jpm',
89
+ 'jpx',
90
+ 'mj2',
91
+ 'aif',
92
+ 'qcp',
93
+ 'odt',
94
+ 'ods',
95
+ 'odp',
96
+ 'xml',
97
+ 'mobi',
98
+ 'heic',
99
+ 'cur',
100
+ 'ktx',
101
+ 'ape',
102
+ 'wv',
103
+ 'dcm',
104
+ 'ics',
105
+ 'glb',
106
+ 'pcap',
107
+ 'dsf',
108
+ 'lnk',
109
+ 'alias',
110
+ 'voc',
111
+ 'ac3',
112
+ 'm4v',
113
+ 'm4p',
114
+ 'm4b',
115
+ 'f4v',
116
+ 'f4p',
117
+ 'f4b',
118
+ 'f4a',
119
+ 'mie',
120
+ 'asf',
121
+ 'ogm',
122
+ 'ogx',
123
+ 'mpc',
124
+ 'arrow',
125
+ 'shp',
126
+ 'aac',
127
+ 'mp1',
128
+ 'it',
129
+ 's3m',
130
+ 'xm',
131
+ 'skp',
132
+ 'avif',
133
+ 'eps',
134
+ 'lzh',
135
+ 'pgp',
136
+ 'asar',
137
+ 'stl',
138
+ 'chm',
139
+ '3mf',
140
+ 'zst',
141
+ 'jxl',
142
+ 'vcf',
143
+ 'jls',
144
+ 'pst',
145
+ 'dwg',
146
+ 'parquet',
147
+ 'class',
148
+ 'arj',
149
+ 'cpio',
150
+ 'ace',
151
+ 'avro',
152
+ 'icc',
153
+ 'fbx',
154
+ 'vsdx',
155
+ 'vtt',
156
+ 'apk',
157
+ 'drc',
158
+ 'lz4',
159
+ 'potx',
160
+ 'xltx',
161
+ 'dotx',
162
+ 'xltm',
163
+ 'ott',
164
+ 'ots',
165
+ 'otp',
166
+ 'odg',
167
+ 'otg',
168
+ 'xlsm',
169
+ 'docm',
170
+ 'dotm',
171
+ 'potm',
172
+ 'pptm',
173
+ 'jar',
174
+ 'jmp',
175
+ 'rm',
176
+ 'sav',
177
+ 'ppsm',
178
+ 'ppsx',
179
+ 'tar.gz',
180
+ 'reg',
181
+ 'dat',
182
+ ];
183
+
184
+ export const mimeTypes = [
185
+ 'image/jpeg',
186
+ 'image/png',
187
+ 'image/gif',
188
+ 'image/webp',
189
+ 'image/flif',
190
+ 'image/x-xcf',
191
+ 'image/x-canon-cr2',
192
+ 'image/x-canon-cr3',
193
+ 'image/tiff',
194
+ 'image/bmp',
195
+ 'image/vnd.ms-photo',
196
+ 'image/vnd.adobe.photoshop',
197
+ 'application/x-indesign',
198
+ 'application/epub+zip',
199
+ 'application/x-xpinstall',
200
+ 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
201
+ 'application/vnd.oasis.opendocument.text',
202
+ 'application/vnd.oasis.opendocument.spreadsheet',
203
+ 'application/vnd.oasis.opendocument.presentation',
204
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
205
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
206
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
207
+ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
208
+ 'application/zip',
209
+ 'application/x-tar',
210
+ 'application/x-rar-compressed',
211
+ 'application/gzip',
212
+ 'application/x-bzip2',
213
+ 'application/x-7z-compressed',
214
+ 'application/x-apple-diskimage',
215
+ 'application/vnd.apache.arrow.file',
216
+ 'video/mp4',
217
+ 'audio/midi',
218
+ 'video/matroska',
219
+ 'video/webm',
220
+ 'video/quicktime',
221
+ 'video/vnd.avi',
222
+ 'audio/wav',
223
+ 'audio/qcelp',
224
+ 'audio/x-ms-asf',
225
+ 'video/x-ms-asf',
226
+ 'application/vnd.ms-asf',
227
+ 'video/mpeg',
228
+ 'video/3gpp',
229
+ 'audio/mpeg',
230
+ 'audio/mp4', // RFC 4337
231
+ 'video/ogg',
232
+ 'audio/ogg',
233
+ 'audio/ogg; codecs=opus',
234
+ 'application/ogg',
235
+ 'audio/flac',
236
+ 'audio/ape',
237
+ 'audio/wavpack',
238
+ 'audio/amr',
239
+ 'application/pdf',
240
+ 'application/x-elf',
241
+ 'application/x-mach-binary',
242
+ 'application/x-msdownload',
243
+ 'application/x-shockwave-flash',
244
+ 'application/rtf',
245
+ 'application/wasm',
246
+ 'font/woff',
247
+ 'font/woff2',
248
+ 'application/vnd.ms-fontobject',
249
+ 'font/ttf',
250
+ 'font/otf',
251
+ 'font/collection',
252
+ 'image/x-icon',
253
+ 'video/x-flv',
254
+ 'application/postscript',
255
+ 'application/eps',
256
+ 'application/x-xz',
257
+ 'application/x-sqlite3',
258
+ 'application/x-nintendo-nes-rom',
259
+ 'application/x-google-chrome-extension',
260
+ 'application/vnd.ms-cab-compressed',
261
+ 'application/x-deb',
262
+ 'application/x-unix-archive',
263
+ 'application/x-rpm',
264
+ 'application/x-compress',
265
+ 'application/x-lzip',
266
+ 'application/x-cfb',
267
+ 'application/x-mie',
268
+ 'application/mxf',
269
+ 'video/mp2t',
270
+ 'application/x-blender',
271
+ 'image/bpg',
272
+ 'image/j2c',
273
+ 'image/jp2',
274
+ 'image/jpx',
275
+ 'image/jpm',
276
+ 'image/mj2',
277
+ 'audio/aiff',
278
+ 'application/xml',
279
+ 'application/x-mobipocket-ebook',
280
+ 'image/heif',
281
+ 'image/heif-sequence',
282
+ 'image/heic',
283
+ 'image/heic-sequence',
284
+ 'image/icns',
285
+ 'image/ktx',
286
+ 'application/dicom',
287
+ 'audio/x-musepack',
288
+ 'text/calendar',
289
+ 'text/vcard',
290
+ 'text/vtt',
291
+ 'model/gltf-binary',
292
+ 'application/vnd.tcpdump.pcap',
293
+ 'audio/x-dsf', // Non-standard
294
+ 'application/x.ms.shortcut', // Invented by us
295
+ 'application/x.apple.alias', // Invented by us
296
+ 'audio/x-voc',
297
+ 'audio/vnd.dolby.dd-raw',
298
+ 'audio/x-m4a',
299
+ 'image/apng',
300
+ 'image/x-olympus-orf',
301
+ 'image/x-sony-arw',
302
+ 'image/x-adobe-dng',
303
+ 'image/x-nikon-nef',
304
+ 'image/x-panasonic-rw2',
305
+ 'image/x-fujifilm-raf',
306
+ 'video/x-m4v',
307
+ 'video/3gpp2',
308
+ 'application/x-esri-shape',
309
+ 'audio/aac',
310
+ 'audio/x-it',
311
+ 'audio/x-s3m',
312
+ 'audio/x-xm',
313
+ 'video/MP1S',
314
+ 'video/MP2P',
315
+ 'application/vnd.sketchup.skp',
316
+ 'image/avif',
317
+ 'application/x-lzh-compressed',
318
+ 'application/pgp-encrypted',
319
+ 'application/x-asar',
320
+ 'model/stl',
321
+ 'application/vnd.ms-htmlhelp',
322
+ 'model/3mf',
323
+ 'image/jxl',
324
+ 'application/zstd',
325
+ 'image/jls',
326
+ 'application/vnd.ms-outlook',
327
+ 'image/vnd.dwg',
328
+ 'application/vnd.apache.parquet',
329
+ 'application/java-vm',
330
+ 'application/x-arj',
331
+ 'application/x-cpio',
332
+ 'application/x-ace-compressed',
333
+ 'application/avro',
334
+ 'application/vnd.iccprofile',
335
+ 'application/x.autodesk.fbx', // Invented by us
336
+ 'application/vnd.visio',
337
+ 'application/vnd.android.package-archive',
338
+ 'application/vnd.google.draco', // Invented by us
339
+ 'application/x-lz4', // Invented by us
340
+ 'application/vnd.openxmlformats-officedocument.presentationml.template',
341
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
342
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
343
+ 'application/vnd.ms-excel.template.macroenabled.12',
344
+ 'application/vnd.oasis.opendocument.text-template',
345
+ 'application/vnd.oasis.opendocument.spreadsheet-template',
346
+ 'application/vnd.oasis.opendocument.presentation-template',
347
+ 'application/vnd.oasis.opendocument.graphics',
348
+ 'application/vnd.oasis.opendocument.graphics-template',
349
+ 'application/vnd.ms-excel.sheet.macroenabled.12',
350
+ 'application/vnd.ms-word.document.macroenabled.12',
351
+ 'application/vnd.ms-word.template.macroenabled.12',
352
+ 'application/vnd.ms-powerpoint.template.macroenabled.12',
353
+ 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
354
+ 'application/java-archive',
355
+ 'application/vnd.rn-realmedia',
356
+ 'application/x-spss-sav',
357
+ 'application/x-ms-regedit',
358
+ 'application/x-ft-windows-registry-hive',
359
+ 'application/x-jmp-data',
360
+ ];
package/util.js ADDED
@@ -0,0 +1,60 @@
1
+ import {StringType} from 'token-types';
2
+
3
+ export function stringToBytes(string, encoding) {
4
+ if (encoding === 'utf-16le') {
5
+ const bytes = [];
6
+ for (let index = 0; index < string.length; index++) {
7
+ const code = string.charCodeAt(index); // eslint-disable-line unicorn/prefer-code-point
8
+ bytes.push(code & 0xFF, (code >> 8) & 0xFF); // High byte
9
+ }
10
+
11
+ return bytes;
12
+ }
13
+
14
+ if (encoding === 'utf-16be') {
15
+ const bytes = [];
16
+ for (let index = 0; index < string.length; index++) {
17
+ const code = string.charCodeAt(index); // eslint-disable-line unicorn/prefer-code-point
18
+ bytes.push((code >> 8) & 0xFF, code & 0xFF); // Low byte
19
+ }
20
+
21
+ return bytes;
22
+ }
23
+
24
+ return [...string].map(character => character.charCodeAt(0)); // eslint-disable-line unicorn/prefer-code-point
25
+ }
26
+
27
+ /**
28
+ Checks whether the TAR checksum is valid.
29
+
30
+ @param {Uint8Array} arrayBuffer - The TAR header `[offset ... offset + 512]`.
31
+ @param {number} offset - TAR header offset.
32
+ @returns {boolean} `true` if the TAR checksum is valid, otherwise `false`.
33
+ */
34
+ export function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
35
+ const readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(/\0.*$/, '').trim(), 8); // Read sum in header
36
+ if (Number.isNaN(readSum)) {
37
+ return false;
38
+ }
39
+
40
+ let sum = 8 * 0x20; // Initialize signed bit sum
41
+
42
+ for (let index = offset; index < offset + 148; index++) {
43
+ sum += arrayBuffer[index];
44
+ }
45
+
46
+ for (let index = offset + 156; index < offset + 512; index++) {
47
+ sum += arrayBuffer[index];
48
+ }
49
+
50
+ return readSum === sum;
51
+ }
52
+
53
+ /**
54
+ ID3 UINT32 sync-safe tokenizer token.
55
+ 28 bits (representing up to 256MB) integer, the msb is 0 to avoid "false syncsignals".
56
+ */
57
+ export const uint32SyncSafeToken = {
58
+ get: (buffer, offset) => (buffer[offset + 3] & 0x7F) | ((buffer[offset + 2]) << 7) | ((buffer[offset + 1]) << 14) | ((buffer[offset]) << 21),
59
+ len: 4,
60
+ };