Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
arraybuffer-mime
Advanced tools
Prepends byte array to indicate mime type of the ArrayBuffer.
npm install arraybuffer-mime
Basic example:
const {
arrayBufferWithMime,
arrayBufferMimeDecouple
} = require('arraybuffer-mime')
// "some image"
const uint8 = new Uint8Array(1)
uint8[0] = 1
const ab = uint8.buffer
const mime = 'image/png'
const abWithMime = arrayBufferWithMime(ab, mime)
const {mime, arrayBuffer} = arrayBufferMimeDecouple(abWithMime)
console.log(mime) // "image/png"
console.log(arrayBuffer) // ArrayBuffer
Example demonstrating sending a binary file over Websockets:
const {
arrayBufferWithMime,
arrayBufferMimeDecouple
} = require('arraybuffer-mime')
const ws = new WebSocket(`ws://localhost:8080/`)
ws.binaryType = 'arraybuffer'
const fileInput = document.querySelector('input[type="file"]')
const file = fileInput.files[0]
const reader = new FileReader()
const readFile = (event) => {
const arrayBuffer = reader.result
const mime = file.type
const abWithMime = arrayBufferWithMime(arrayBuffer, mime)
ws.send(abWithMime)
}
reader.addEventListener('load', readFile)
reader.readAsArrayBuffer(file)
ws.on('message', (event) => {
const abWithMime = event.data
const {mime, arrayBuffer} = arrayBufferMimeDecouple(abWithMime)
const blob = new Blob([arrayBuffer], {type: mime})
const url = window.URL.createObjectURL(blob)
console.log(url)
})
npm test
FAQs
Prepends byte array to indicate mime type of the ArrayBuffer.
The npm package arraybuffer-mime receives a total of 1 weekly downloads. As such, arraybuffer-mime popularity was classified as not popular.
We found that arraybuffer-mime demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.