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.
A client library for the IPFS API.
If you're NOT using browserify, then use the included standalone file ipfsapi.min.js. This exports a ipfsAPI constructor on window.
Install Via NPM:
$ npm install --save ipfs-api
Initialize with:
//load module
var ipfs_api = require('ipfs-api');
//connect to ipfs daemon API server
var ipfs = ipfs_api('localhost', '5001'); //leaving out the arguments will default to these values
If are using this module in a browser with something like browserify, then you will get an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure. The ipfs server rejects requests from unknown domains by default. You can whitelist the domain that you are calling from by exporting API_ORIGIN and restarting the daemon, like:
export API_ORIGIN="http://localhost:8080"
ipfs daemon
Level 1 commands are simple commands
Add a file (where file is any data) to ipfs returning the hash and name. The name value will only be set if you are actually sending a file. A single or array of files can be used.
Usage
ipfs.add(files, function(err, res) {
if(err || !res) return console.error(err)
res.forEach(function(file) {
console.log(file.Hash)
console.log(file.Name)
})
})
files
can be a mixed array of filenames or buffers of data. A single value is
also acceptable.
Example
var files = ["../files/hello.txt", new Buffer("ipfs!")]
var files = "../files/hello.txt"
Curl
curl 'http://localhost:5001/api/v0/add?stream-cannels=true' \
-H 'content-type: multipart/form-data; boundary=a831rwxi1a3gzaorw1w2z49dlsor' \
-H 'Connection: keep-alive' \
--data-binary $'--a831rwxi1a3gzaorw1w2z49dlsor\r\nContent-Type: application/octet-stream\r\nContent-Disposition: file; name="file"; filename="Hello.txt"\r\n\r\nhello--a831rwxi1a3gzaorw1w2z49dlsor--' --compressed
Response
[{
Hash: string,
Name: string
}, ...]
The name value will only be set for actual files
Retrieve the contents of a single, or array of hashes
Usage
ipfs.cat(hashs, function(err, res) {
if(err || !res) return console.error(err)
if(res.readable) {
// Returned as a stream
res.pipe(process.stdout)
} else {
// Returned as a string
console.log(res)
}
})
Curl
curl "http://localhost:5001/api/v0/cat?arg=<hash>&stream-channels=true"
Response
The response is either a readable stream, or a string.
Get the node structure of a hash, included in it is a hash and array to links.
Usage
ipfs.ls(hashs, function(err, res) {
if(err || !res) return console.error(err)
res.Objects.forEach(function(node) {
console.log(node.Hash)
console.log("Links [%d]", node.Links.length)
node.Links.forEach(function(link, i) {
console.log("[%d]", i, link)
})
})
})
Curl
curl "http://localhost:5001/api/v0/ls?arg=<hash>&stream-channels=true"
Response
{
Objects: [
{
Hash: string,
Links: [{
Name: string,
Hash: string,
Size: number
}, ...]
},
....
]
}
version
commands
Level 2 commands are simply named spaced wrapped commands
Curl
curl 'http://localhost:5001/api/v0/object/get?arg=QmYEqnfCZp7a39Gxrgyv3qRS4MoCTGjegKV6zroU3Rvr52&stream-channels=true' --compressed
Response
{
Links: [{
Name: string,
Hash: string,
Size: number
}, ...],
Data: string
Data is base64 encoded
FAQs
A client library for the IPFS HTTP API
The npm package ipfs-api receives a total of 5,115 weekly downloads. As such, ipfs-api popularity was classified as popular.
We found that ipfs-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
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.