file-type 14.6.2 → 14.7.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/core.d.ts +7 -3
- package/core.js +27 -1
- package/package.json +4 -2
- package/readme.md +3 -1
- package/supported.js +6 -2
package/core.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare namespace core {
|
|
|
23
23
|
| 'icns'
|
|
24
24
|
| 'jxr'
|
|
25
25
|
| 'psd'
|
|
26
|
+
| 'indd'
|
|
26
27
|
| 'zip'
|
|
27
28
|
| 'tar'
|
|
28
29
|
| 'rar'
|
|
@@ -134,7 +135,8 @@ declare namespace core {
|
|
|
134
135
|
| 'avif'
|
|
135
136
|
| 'eps'
|
|
136
137
|
| 'lzh'
|
|
137
|
-
| 'pgp'
|
|
138
|
+
| 'pgp'
|
|
139
|
+
| 'asar';
|
|
138
140
|
|
|
139
141
|
type MimeType =
|
|
140
142
|
| 'image/jpeg'
|
|
@@ -149,6 +151,7 @@ declare namespace core {
|
|
|
149
151
|
| 'image/icns'
|
|
150
152
|
| 'image/vnd.ms-photo'
|
|
151
153
|
| 'image/vnd.adobe.photoshop'
|
|
154
|
+
| 'application/x-indesign'
|
|
152
155
|
| 'application/epub+zip'
|
|
153
156
|
| 'application/x-xpinstall'
|
|
154
157
|
| 'application/vnd.oasis.opendocument.text'
|
|
@@ -260,7 +263,8 @@ declare namespace core {
|
|
|
260
263
|
| 'application/vnd.sketchup.skp'
|
|
261
264
|
| 'image/avif'
|
|
262
265
|
| 'application/x-lzh-compressed'
|
|
263
|
-
| 'application/pgp-encrypted'
|
|
266
|
+
| 'application/pgp-encrypted'
|
|
267
|
+
| 'application/x-asar';
|
|
264
268
|
|
|
265
269
|
interface FileTypeResult {
|
|
266
270
|
/**
|
|
@@ -332,7 +336,7 @@ declare namespace core {
|
|
|
332
336
|
/**
|
|
333
337
|
Supported file extensions.
|
|
334
338
|
*/
|
|
335
|
-
const extensions:
|
|
339
|
+
const extensions: Set<core.FileExtension>;
|
|
336
340
|
|
|
337
341
|
/**
|
|
338
342
|
Supported MIME types.
|
package/core.js
CHANGED
|
@@ -1195,6 +1195,24 @@ async function _fromTokenizer(tokenizer) {
|
|
|
1195
1195
|
};
|
|
1196
1196
|
}
|
|
1197
1197
|
|
|
1198
|
+
if (check([0x04, 0x00, 0x00, 0x00]) && buffer.length >= 16) { // Rough & quick check Pickle/ASAR
|
|
1199
|
+
const jsonSize = buffer.readUInt32LE(12);
|
|
1200
|
+
if (jsonSize > 12 && jsonSize < 240 && buffer.length >= jsonSize + 16) {
|
|
1201
|
+
try {
|
|
1202
|
+
const header = buffer.slice(16, jsonSize + 16).toString();
|
|
1203
|
+
const json = JSON.parse(header);
|
|
1204
|
+
// Check if Pickle is ASAR
|
|
1205
|
+
if (json.files) { // Final check, assuring Pickle/ASAR format
|
|
1206
|
+
return {
|
|
1207
|
+
ext: 'asar',
|
|
1208
|
+
mime: 'application/x-asar'
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
} catch (_) {
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1198
1216
|
if (
|
|
1199
1217
|
check([0x30, 0x30, 0x30, 0x30, 0x30, 0x30], {offset: 148, mask: [0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8]}) && // Valid tar checksum
|
|
1200
1218
|
tarHeaderChecksumMatches(buffer)
|
|
@@ -1275,6 +1293,13 @@ async function _fromTokenizer(tokenizer) {
|
|
|
1275
1293
|
};
|
|
1276
1294
|
}
|
|
1277
1295
|
|
|
1296
|
+
if (check([0x06, 0x06, 0xED, 0xF5, 0xD8, 0x1D, 0x46, 0xE5, 0xBD, 0x31, 0xEF, 0xE7, 0xFE, 0x74, 0xB7, 0x1D])) {
|
|
1297
|
+
return {
|
|
1298
|
+
ext: 'indd',
|
|
1299
|
+
mime: 'application/x-indesign'
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1278
1303
|
// Increase sample size from 256 to 512
|
|
1279
1304
|
await tokenizer.peekBuffer(buffer, {length: Math.min(512, tokenizer.fileInfo.size), mayBeLess: true});
|
|
1280
1305
|
|
|
@@ -1360,7 +1385,8 @@ const stream = readableStream => new Promise((resolve, reject) => {
|
|
|
1360
1385
|
const pass = new stream.PassThrough();
|
|
1361
1386
|
let outputStream;
|
|
1362
1387
|
if (stream.pipeline) {
|
|
1363
|
-
outputStream = stream.pipeline(readableStream, pass, () => {
|
|
1388
|
+
outputStream = stream.pipeline(readableStream, pass, () => {
|
|
1389
|
+
});
|
|
1364
1390
|
} else {
|
|
1365
1391
|
outputStream = readableStream.pipe(pass);
|
|
1366
1392
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-type",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.7.0",
|
|
4
4
|
"description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/file-type",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"icns",
|
|
67
67
|
"jxr",
|
|
68
68
|
"psd",
|
|
69
|
+
"indd",
|
|
69
70
|
"zip",
|
|
70
71
|
"tar",
|
|
71
72
|
"rar",
|
|
@@ -177,7 +178,8 @@
|
|
|
177
178
|
"avif",
|
|
178
179
|
"eps",
|
|
179
180
|
"lzh",
|
|
180
|
-
"pgp"
|
|
181
|
+
"pgp",
|
|
182
|
+
"asar"
|
|
181
183
|
],
|
|
182
184
|
"devDependencies": {
|
|
183
185
|
"@types/node": "^13.1.4",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# file-type [](https://travis-ci.
|
|
1
|
+
# file-type [](https://travis-ci.com/github/sindresorhus/file-type)
|
|
2
2
|
|
|
3
3
|
> Detect the file type of a Buffer/Uint8Array/ArrayBuffer
|
|
4
4
|
|
|
@@ -289,6 +289,7 @@ Returns a set of supported MIME types.
|
|
|
289
289
|
- [`icns`](https://en.wikipedia.org/wiki/Apple_Icon_Image_format)
|
|
290
290
|
- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
|
|
291
291
|
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
|
|
292
|
+
- [`indd`](https://en.wikipedia.org/wiki/Adobe_InDesign#File_format)
|
|
292
293
|
- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
|
|
293
294
|
- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
|
|
294
295
|
- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
|
|
@@ -401,6 +402,7 @@ Returns a set of supported MIME types.
|
|
|
401
402
|
- [`eps`](https://en.wikipedia.org/wiki/Encapsulated_PostScript) - Encapsulated PostScript
|
|
402
403
|
- [`lzh`](https://en.wikipedia.org/wiki/LHA_(file_format)) - LZH archive
|
|
403
404
|
- [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy
|
|
405
|
+
- [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications
|
|
404
406
|
|
|
405
407
|
*Pull requests are welcome for additional commonly used file types.*
|
|
406
408
|
|
package/supported.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = {
|
|
|
21
21
|
'icns',
|
|
22
22
|
'jxr',
|
|
23
23
|
'psd',
|
|
24
|
+
'indd',
|
|
24
25
|
'zip',
|
|
25
26
|
'tar',
|
|
26
27
|
'rar',
|
|
@@ -132,7 +133,8 @@ module.exports = {
|
|
|
132
133
|
'avif',
|
|
133
134
|
'eps',
|
|
134
135
|
'lzh',
|
|
135
|
-
'pgp'
|
|
136
|
+
'pgp',
|
|
137
|
+
'asar'
|
|
136
138
|
],
|
|
137
139
|
mimeTypes: [
|
|
138
140
|
'image/jpeg',
|
|
@@ -146,6 +148,7 @@ module.exports = {
|
|
|
146
148
|
'image/bmp',
|
|
147
149
|
'image/vnd.ms-photo',
|
|
148
150
|
'image/vnd.adobe.photoshop',
|
|
151
|
+
'application/x-indesign',
|
|
149
152
|
'application/epub+zip',
|
|
150
153
|
'application/x-xpinstall',
|
|
151
154
|
'application/vnd.oasis.opendocument.text',
|
|
@@ -258,6 +261,7 @@ module.exports = {
|
|
|
258
261
|
'application/vnd.sketchup.skp',
|
|
259
262
|
'image/avif',
|
|
260
263
|
'application/x-lzh-compressed',
|
|
261
|
-
'application/pgp-encrypted'
|
|
264
|
+
'application/pgp-encrypted',
|
|
265
|
+
'application/x-asar'
|
|
262
266
|
]
|
|
263
267
|
};
|