Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
audio-type
Advanced tools
The 'audio-type' npm package is used to detect the file type of a given audio buffer. It supports various audio formats and provides a simple interface to determine the type of audio data.
Detect Audio Type
This feature allows you to detect the type of an audio file by reading its buffer. The code sample demonstrates how to read an audio file into a buffer and then use the 'audio-type' package to determine its type.
const audioType = require('audio-type');
const fs = require('fs');
const buffer = fs.readFileSync('path/to/audio/file');
const type = audioType(buffer);
console.log(type); // e.g., 'mp3', 'wav', etc.
The 'file-type' package is a more general-purpose library that can detect the file type of various file formats, including audio, video, images, and more. It provides a broader range of file type detection compared to 'audio-type', which is specialized for audio files.
The 'music-metadata' package is used to parse audio files and extract metadata such as format, duration, and tags. While it provides more detailed information about audio files, including metadata, it also includes functionality to detect the file type, making it a more comprehensive tool compared to 'audio-type'.
Detect the audio type of a ArrayBuffer/Uint8Array
$ npm i audio-type
import readChunk from 'read-chunk'; // npm install read-chunk
import audioType from 'audio-type';
var buffer = readChunk.sync('meow.wav', 0, 12);
audioType(buffer);
//=> wav
import audioType from './audio-type.js'
var xhr = new XMLHttpRequest();
xhr.open('GET', 'meow.flac');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
audioType(this.response);
//=> flac
};
xhr.send();
Returns: 'mp3'
, 'oga'
, 'flac'
, 'wav'
, 'm4a'
, 'opus'
, 'qoa'
Type: buffer
(Node.js), arrayBuffer
, uint8array
It only needs the first 12 bytes.
MIT • ॐ
FAQs
Detect the audio type of a Buffer/Uint8Array
We found that audio-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.