
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
ipfs-unixfs-exporter
Advanced tools
JavaScript implementation of the exporter used by IPFS to handle Files
> npm install ipfs-unixfs-exporter
// Create an export source pull-stream cid or ipfs path you want to export and a
// <dag or ipld-resolver instance> to fetch the file from
const exporter = require('ipfs-unixfs-exporter')
const pull = require('pull-stream/pull')
const { stdout } = require('pull-stdio')
const options = {}
pull(
exporter(cid, ipld, options),
collect((error, files) => {
if (error) {
// ...handle error
}
// Set up a pull stream that sends the file content to process.stdout
pull(
// files[0].content is a pull-stream that contains the bytes of the file
files[0].content,
stdout()
)
})
)
const exporter = require('ipfs-unixfs-exporter')
Uses the given dag API or an ipld-resolver instance to fetch an IPFS UnixFS object(s) by their CID.
Creates a new pull stream that outputs objects of the form
{
path: 'a name',
content: <pull stream>
}
offset
and length
offset
and length
arguments can optionally be passed to the exporter function. These will cause the returned stream to only emit bytes starting at offset
and with length of length
.
See the tests for examples of using these arguments.
const exporter = require('ipfs-unixfs-exporter')
const pull = require('pull-stream')
const drain = require('pull-stream/sinks/drain')
pull(
exporter(cid, ipld, {
offset: 0,
length: 10
})
drain((file) => {
// file.content is a pull stream containing only the first 10 bytes of the file
})
)
fullPath
If specified the exporter will emit an entry for every path component encountered.
const exporter = require('ipfs-unixfs-exporter')
const pull = require('pull-stream')
const collect = require('pull-stream/sinks/collect')
pull(
exporter('QmFoo.../bar/baz.txt', ipld, {
fullPath: true
})
collect((err, files) => {
console.info(files)
// [{
// depth: 0,
// name: 'QmFoo...',
// path: 'QmFoo...',
// size: ...
// hash: Buffer
// content: undefined
// type: 'dir'
// }, {
// depth: 1,
// name: 'bar',
// path: 'QmFoo.../bar',
// size: ...
// hash: Buffer
// content: undefined
// type: 'dir'
// }, {
// depth: 2,
// name: 'baz.txt',
// path: 'QmFoo.../bar/baz.txt',
// size: ...
// hash: Buffer
// content: <Pull stream>
// type: 'file'
// }]
//
})
)
maxDepth
If specified the exporter will only emit entries up to the specified depth.
const exporter = require('ipfs-unixfs-exporter')
const pull = require('pull-stream')
const collect = require('pull-stream/sinks/collect')
pull(
exporter('QmFoo.../bar/baz.txt', ipld, {
fullPath: true,
maxDepth: 1
})
collect((err, files) => {
console.info(files)
// [{
// depth: 0,
// name: 'QmFoo...',
// path: 'QmFoo...',
// size: ...
// hash: Buffer
// content: undefined
// type: 'dir'
// }, {
// depth: 1,
// name: 'bar',
// path: 'QmFoo.../bar',
// size: ...
// hash: Buffer
// content: undefined
// type: 'dir'
// }]
//
})
)
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
FAQs
JavaScript implementation of the UnixFs exporter used by IPFS
The npm package ipfs-unixfs-exporter receives a total of 20,166 weekly downloads. As such, ipfs-unixfs-exporter popularity was classified as popular.
We found that ipfs-unixfs-exporter demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.