Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

tweetcat

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tweetcat - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+32
-19
index.js

@@ -24,3 +24,4 @@ 'use strict'

var rs = through2()
var buffer = []
var queue = []
var maxDataLength = 140 - opts.screen_name.length - 2
var synSent = false

@@ -48,3 +49,3 @@ var connected = false

if (err) return cb(err)
debug('got user id %s for username %s', data.id_str, username)
debug('got user id %s for %s', data.id_str, username)
cb(null, data.id_str)

@@ -54,12 +55,11 @@ })

function ondata (data) {
var data = data.toString().trim()
debug('received data on stream', data)
function ondata (buf) {
debug('received data on stream', buf)
// TODO: Implement back pressure
buffer.push(data)
addToQueue(buf)
if (!connected) return syn()
sendBuffer()
sendQueue()
}

@@ -81,3 +81,3 @@

// `tweet.in_reply_to_user_id_str` and ONLY care about the @-mention.
debug('ignoring non-reply tweet (id: %s, reply-to: %s, connected: %s)', tweet.id_str, tweet.in_reply_to_user_id_str, connected)
debug('ignoring non-reply tweet (id: %s, reply-to: %s)', tweet.id_str, tweet.in_reply_to_user_id_str)
return

@@ -88,3 +88,3 @@ }

if (incomingSyn.test(tweet.text)) {
debug('detected incoming syn pkg (id: %s, connected: %s)', tweet.id_str, connected)
debug('detected incoming syn pkg (id: %s)', tweet.id_str)
lastMsgId = tweet.id_str

@@ -97,10 +97,10 @@ synAck()

if (incomingSynAck.test(tweet.text)) {
debug('detected incoming syn-ack pkg (id: %s, connected: %s)', tweet.id_str, connected)
debug('detected incoming syn-ack pkg (id: %s)', tweet.id_str)
lastMsgId = tweet.id_str
connected = true
sendBuffer()
sendQueue()
return
}
debug('new tweet by %s (id: %s, connected: %s)', remote, tweet.id_str, connected, tweet.text)
debug('new tweet by %s (id: %s)', remote, tweet.id_str, tweet.text)

@@ -111,2 +111,3 @@ if (!connected) return debug('ignoring tweet - not yet connected!')

var msg = tweet.text.replace(incomingMention, '')
msg = new Buffer(msg, 'base64').toString('utf8')

@@ -116,8 +117,20 @@ debug('relaying message (id: %s)', tweet.id_str, msg)

// TODO: Handle back pressure
rs.write(msg + '\n') // write decoded message to writable stream
rs.write(msg) // write decoded message to writable stream
}
function sendBuffer () {
function addToQueue (buf) {
var rest = new Buffer('')
var encoded = buf.toString('base64')
while (encoded.length > maxDataLength) {
rest = Buffer.concat([buf.slice(-1), rest])
buf = buf.slice(0, -1)
encoded = buf.toString('base64')
}
queue.push(encoded)
if (rest.length) addToQueue(rest)
}
function sendQueue () {
// TODO: Handle raise condition
var data = buffer.shift()
var data = queue.shift()
if (!data) return

@@ -128,3 +141,3 @@ var msg = util.format('@%s %s', remote, data)

if (err) return rs.destroy(err)
sendBuffer()
sendQueue()
})

@@ -139,3 +152,3 @@ }

if (err) return rs.destroy(err)
debug('syn pkg sent successfully (id: %s, connected: %s)', id, connected)
debug('syn pkg sent successfully (id: %s)', id)
})

@@ -148,5 +161,5 @@ }

if (err) return rs.destroy(err)
debug('syn-ack pkg sent successfully (id: %s, connected: %s)', id, connected)
debug('syn-ack pkg sent successfully (id: %s)', id)
connected = true
sendBuffer()
sendQueue()
})

@@ -153,0 +166,0 @@ }

{
"name": "tweetcat",
"version": "0.0.1",
"version": "0.0.2",
"description": "p2p pipe across the internet using Twitter as a transport stream",

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

@@ -10,3 +10,3 @@ # tweetcat

```
npm install -g watson/tweetcat
npm install -g tweetcat
```

@@ -32,4 +32,4 @@

- [ ] Allow transfer of binary data
- [ ] Allow transfer of data larger than 140 chars
- [x] ~~Allow transfer of binary data~~
- [x] ~~Allow transfer of data larger than 140 chars~~
- [x] ~~Find solution to distributing Twitter API consumer key/secret~~

@@ -36,0 +36,0 @@ - [x] ~~Implement two-way handshake so that one side of the conversation

@@ -1,1 +0,1 @@

{"user_id":"3253697520","screen_name":"tweetcat001","x_auth_expires":"0","token":"3253697520-b4WvNhEW1XLE5rczbNygRTLp6G7SCZ0Qi8UtHec","secret":"nUZrphcSqYy266cQZhMCcfsCOPgyyboGRhNFD1gablTn3"}
{"user_id":"3253697520","screen_name":"tweetcat001","x_auth_expires":"0","token":"3253697520-FEPUQWobB1S6TpVf3SC5r3FEEks7D9pTvWbWQoP","secret":"zO57EosNmQIazpSJ2acMYjGygADhI941HzYp1NFV9X7ta"}

@@ -1,1 +0,1 @@

{"user_id":"3343336215","screen_name":"tweetcat003","x_auth_expires":"0","token":"3343336215-9QA8ARrKq5q8lNCx7Di7Hn04K44YIerKMLTs3VQ","secret":"Ukf4jt7Yv0WIxSAOEd0DjQjAMErLaNI66HBCZkZQITy8Z"}
{"user_id":"3343336215","screen_name":"tweetcat003","x_auth_expires":"0","token":"3343336215-br02lCYPFZcdJCBRaUrgSWPX0FoFdzPZar38xkc","secret":"eIOWz7N3YE9AKQjYJyTFAHA1q9LonJi6tXvGrMcVver7r"}