Socket
Socket
Sign inDemoInstall

file-type

Package Overview
Dependencies
Maintainers
2
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-type - npm Package Compare versions

Comparing version 16.1.0 to 16.2.0

6

core.d.ts

@@ -139,3 +139,4 @@ /// <reference types="node"/>

| 'stl'
| 'chm';
| 'chm'
| '3mf';

@@ -270,3 +271,4 @@ type MimeType =

| 'model/stl'
| 'application/vnd.ms-htmlhelp';
| 'application/vnd.ms-htmlhelp'
| 'model/3mf';

@@ -273,0 +275,0 @@ interface FileTypeResult {

@@ -58,11 +58,2 @@ 'use strict';

async function _checkSequence(sequence, tokenizer, ignoreBytes) {
const buffer = Buffer.alloc(minimumBytes);
await tokenizer.ignore(ignoreBytes);
await tokenizer.peekBuffer(buffer, {mayBeLess: true});
return buffer.includes(Buffer.from(sequence));
}
async function fromTokenizer(tokenizer) {

@@ -83,3 +74,2 @@ try {

const checkString = (header, options) => check(stringToBytes(header), options);
const checkSequence = (sequence, ignoreBytes) => _checkSequence(sequence, tokenizer, ignoreBytes);

@@ -323,2 +313,9 @@ // Keep reading until EOF if the file size is unknown.

if (zipHeader.filename.startsWith('3D/') && zipHeader.filename.endsWith('.model')) {
return {
ext: '3mf',
mime: 'model/3mf'
};
}
// The docx, xlsx and pptx file types extend the Office Open XML file format:

@@ -595,5 +592,9 @@ // https://en.wikipedia.org/wiki/Office_Open_XML_file_formats

if (checkString('%PDF')) {
await tokenizer.ignore(1350);
const maxBufferSize = 10 * 1024 * 1024;
const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size));
await tokenizer.readBuffer(buffer, {mayBeLess: true});
// Check if this is an Adobe Illustrator file
const isAiFile = await checkSequence('Adobe Illustrator', 1350);
if (isAiFile) {
if (buffer.includes(Buffer.from('AIPrivateData'))) {
return {

@@ -600,0 +601,0 @@ ext: 'ai',

{
"name": "file-type",
"version": "16.1.0",
"version": "16.2.0",
"description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",

@@ -183,3 +183,4 @@ "license": "MIT",

"stl",
"chm"
"chm",
"3mf"
],

@@ -186,0 +187,0 @@ "devDependencies": {

@@ -408,2 +408,3 @@ # file-type

- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
- [`3mf`](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) - 3D Manufacturing Format

@@ -410,0 +411,0 @@ *Pull requests are welcome for additional commonly used file types.*

@@ -137,3 +137,4 @@ 'use strict';

'stl',
'chm'
'chm',
'3mf'
],

@@ -268,4 +269,5 @@ mimeTypes: [

'model/stl',
'application/vnd.ms-htmlhelp'
'application/vnd.ms-htmlhelp',
'model/3mf'
]
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc