Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
perma-torrent
Advanced tools
Perma-Torrent persists everything to IndexedDB so the torrent data does not disappear when the web page is closed. This also means that the torrent data is shared across all web pages so only one page has to do the downloading while any number of web pages can stream the downloaded data. The torrent data is even accessible from within web workers!
Perma-Torrent makes extensive use of WebTorrent so why not just use WebTorrent? The main reason Perma-Torrent was created was because Service Workers and other Web Workers do not have access to the WebRTC api so they cannot use WebTorrent to download torrents. Perma-Torrent bridges this gap by allowing the downloaded torrent data to be streamed from all web workers and web pages.
Add a torrent then stream a file
var pt = new PermaTorrent()
pt.startSeeder()
return pt.add('http://example.com/foobar.torrent')
.then(torrent => {
let file = torrent.getFile('foobar.txt')
let stream = file.getStream()
})
Add a torrent then stream a file in a web worker
In a web page:
var pt = new PermaTorrent()
// Only web pages can download torrents since
// web workers do not have access to the WebRTC api
pt.startSeeder()
In a web worker:
var pt = new PermaTorrent()
return pt.add('http://example.com/foobar.torrent')
.then(torrent => {
let file = torrent.getFile('foobar.txt')
let stream = file.getStream()
})
var pt = new PermaTorrent([opts])
All instances by default share the same underlying storage so adding a torrent to one instance adds it to all instances. To separate instances from one other define opts.namespace
. The opts
argument can take the following properties:
opts.namespace
- Unique string used to insulate instances from each other. Defaults to 'permatorrent'pt.add(torrentBuffer).then(torrent => {})
Adds the given torrent to the instance and all other instances within the same namespace. torrentBuffer
must be a buffer of the .torrent file. torrent
is an instance of Torrent
which is documented below.
pt.getAll().then(torrents => {})
Returns all the torrents that PermaTorrent holds. torrents
is an array of Torrent
instances.
pt.startSeeder()
Starts the seeder which does the actual downloading and uploading of torrents. This method can only be called in web pages and not in web workers.
pt.remove(infoHash).then(() => {})
Removes the given torrent with the given infoHash
pt.destroy()
Frees the internal resources of the instance.
torrent.name
The name of the torrent
torrent.length
The size of the torrent in bytes
torrent.infoHash
The content based hash of the torrent that uniquely identifies it
torrent.files
An array of File
instances that allow for the streaming of the file's data.
var file = torrent.getFile(filePath)
Returns the File
instance whose path in the torrent matches the given filePath
. If no file is found then undefined
is returned.
file.name
The file name
file.path
The path of the fileInfo
file.length
The size of the file
var stream = file.getStream([opts])
Returns a NodeJS Readable stream for the file. The file can be streamed while it is being downloaded and be sure to call pt.startSeeder()
in at least one instance. opts
can take the following properties:
opts.start
- The byte offset to start streaming from within the fileopts.end
- The byte offset to end the streamingvar webStream = file.getWebStream([opts])
Returns a WhatWG Readable stream for the file. This type of stream is new and only available in a few browser; this method throws if it is called and the browser does not support this type of stream. opts
can take the following properties:
opts.start
- The byte offset to start streaming from within the fileopts.end
- The byte offset to end the streamingReturns a Blob of the file's data. opts
can take the following properties:
opts.start
- The byte offset to start the blob fromopts.end
- The byte offset to end atFAQs
Persistent torrent client for web browsers and web workers
The npm package perma-torrent receives a total of 1 weekly downloads. As such, perma-torrent popularity was classified as not popular.
We found that perma-torrent 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.