Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

torrent-properties

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

torrent-properties - npm Package Compare versions

Comparing version 1.1.9 to 1.2.0

example/data

6

example/client.js

@@ -11,5 +11,5 @@ const WebTorrentProperties = require('./extend')

client.uploadProp({address: '50105b102fa4e5c666fbdb218393aee25d295c4c1de0e45c814e1ec1fa47c6cc', secret: '928d3dec6b3aa7fe51a553f77d3a87c4ff5fbf4692c03e458996afce754d882950105b102fa4e5c666fbdb218393aee25d295c4c1de0e45c814e1ec1fa47c6cc'}, false, path.resolve('./test1'), {}, (torrent, data) => {
console.log(torrent.address)
console.log(data)
client.uploadProp({address: '50105b102fa4e5c666fbdb218393aee25d295c4c1de0e45c814e1ec1fa47c6cc', secret: '928d3dec6b3aa7fe51a553f77d3a87c4ff5fbf4692c03e458996afce754d882950105b102fa4e5c666fbdb218393aee25d295c4c1de0e45c814e1ec1fa47c6cc'}, 3, false, path.resolve('./test1'), {}, (torrent, data) => {
console.log(torrent.address, torrent.infoHash, torrent.seq, torrent.own)
console.log(data.address, data.infoHash, data.seq, data.own)
})

@@ -16,0 +16,0 @@

@@ -22,3 +22,3 @@ const Webtorrent = require('webtorrent')

torrent.address = propData.address
torrent.sequence = propData.sequence
torrent.seq = propData.seq
torrent.own = propData.own

@@ -30,5 +30,5 @@ return callback(torrent, propData)

}
uploadProp(keypair, manage, data, opts, callback){
uploadProp(keypair, seq, manage, data, opts, callback){
this.seed(data, opts, torrent => {
this.properties.publish(keypair, torrent.infoHash, manage, (resError, propData) => {
this.properties.publish(keypair, torrent.infoHash, seq, manage, (resError, propData) => {
if(resError){

@@ -39,3 +39,3 @@ console.log(resError)

torrent.address = propData.address
torrent.sequence = propData.sequence
torrent.seq = propData.seq
torrent.own = propData.own

@@ -42,0 +42,0 @@ return callback(torrent, propData)

@@ -74,4 +74,8 @@ const DHT = require('bittorrent-dht')

if(res){
this.check[i].infoHash = res.getData.v && res.getData.v.ih ? res.getData.v.ih : this.check[i].infoHash
this.check[i].seq = res.getData.seq || res.getData.seq === 0 ? res.getData.seq : this.check[i].seq
if(res.getData.v && res.getData.v.ih){
this.check[i].infoHash = res.getData.v.ih.toString('hex')
}
if(res.getData.seq){
this.check[i].seq = res.getData.seq
}
this.check[i].getData = res.getData

@@ -85,3 +89,3 @@ this.check[i].putData = res.putData

} else {
resolve({hash, number})
resolve({hash: hash.toString('hex'), number})
}

@@ -99,3 +103,5 @@ })

fs.writeFileSync('./data', JSON.stringify(this.check.map(main => {return {address: main.address, infoHash: main.infoHash, seq: main.seq, isActive: main.isActive}})))
setTimeout(this.keepItUpdated, 3600000)
setTimeout(() => {
this.keepItUpdated()
}, 3600000)
}

@@ -108,6 +114,3 @@

removeProperty(address, callback){
if(!callback){
callback = noop
}
removeProperty(address){

@@ -119,5 +122,5 @@ let lookAtProperty = this.getProperty(address, false)

// this.check.splice(lookAtProperty, 1)
return callback(null, 'address has been removed')
return 'address has been removed'
} else {
return callback(new Error('address is not managed'))
return 'address is not managed'
}

@@ -186,3 +189,3 @@

} else if(res){
const infoHash = res.v.ih
const infoHash = res.v.ih.toString('hex')
const seq = res.seq ? res.seq : 0

@@ -211,3 +214,3 @@

publish (keypair, infoHash, manage, callback) {
publish (keypair, infoHash, seq, manage, callback) {

@@ -217,10 +220,11 @@ if (!callback) {

}
if(!infoHash){
if(!infoHash || typeof(infoHash) !== 'string'){
return callback(new Error('must have infoHash'))
} else if((!keypair) || (!keypair.address || !keypair.secret)){
}
if(!seq || typeof(seq) !== 'number'){
seq = 1
}
if((!keypair) || (!keypair.address || !keypair.secret)){
keypair = this.createKeypair(false)
}
// const keypair = !address || !secret ? this.createKeypair(false) : {address, secret}
let propertyData = null

@@ -232,2 +236,5 @@ if(manage){

}
if(propertyData && propertyData.seq){
seq = propertyData.seq + 1
}
}

@@ -237,3 +244,2 @@

const buffSecKey = Buffer.from(keypair.secret, 'hex')
const seq = propertyData ? propertyData.seq + 1 : 0
const getData = {k: buffAddKey, v: {ih: Buffer.from(infoHash, 'hex')}, seq, sign: (buf) => {return sign(buf, buffAddKey, buffSecKey)}}

@@ -257,3 +263,3 @@

callback(null, {magnetURI, infoHash, seq, address: keypair.address, secret: keypair.secret, own: true, hash})
callback(null, {magnetURI, infoHash, seq, address: keypair.address, secret: keypair.secret, own: true, hash: hash.toString('hex')})
})

@@ -281,3 +287,3 @@ }

} else {
return callback(null, {getData, putData: {hash, number}})
return callback(null, {getData, putData: {hash: hash.toString('hex'), number}})
}

@@ -284,0 +290,0 @@ })

{
"name": "torrent-properties",
"version": "1.1.9",
"version": "1.2.0",
"description": "BEP 46",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc