New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

omegle-node

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

omegle-node - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

5

examples/mitm.js

@@ -1,3 +0,4 @@

var Omegle = require('../index');
var om1 = new Omegle(), om2 = new Omegle;
//jshint node:true
var Omegle = require('../index');
var om1 = new Omegle(), om2 = new Omegle();

@@ -4,0 +5,0 @@ //-----------------------Stranger-1--------------------------//

3

examples/omegle.js

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

//jshint node:true
var Omegle = require('../index');

@@ -67,5 +68,5 @@ var om = new Omegle();

var topics = ['bot','nodejs']
var topics = ['bot','nodejs'];
om.connect(topics);
//call om.disconnect() before you call connect() again.

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

//jshint node:true
var Omegle = require('../index');

@@ -29,2 +30,2 @@ var om = new Omegle();

});
om.connect();
om.connect();

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

//jshint node:true
//jshint esversion:6
var request = require('request');

@@ -5,351 +7,281 @@ var ee = require('events').EventEmitter;

var qs = require('querystring');
var Omegle = function()
{
ee.call(this);
this.useragent = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0';
this.language = 'en';
var url = 'http://front1.omegle.com';
var gotID = false;
var isConnected = false;
var _this = this;
var lastEvent = ''; //stopLookingForCommonLikes only works when this is set to 'waiting'.
var id='';
var typing = false;
var challenge = ''; // to store recaptcha challenge.
var challengeLink = '';
//to check if the client is connected to the server
this.connected = function(){
return isConnected;
}
var randID = function(){
var charset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
var str='';
for(i=0; i<8; ++i)
str+=charset.charAt(Math.floor((Math.random() * (charset.length+1))));
return str;
}
var getResponse = function(path, data, callback, method='POST'){
var qsArr = ['/status','/start']; //these paths use qs, others take urlencoded data.
var options = {
url: url+path,
headers: {
var Omegle = function () {
ee.call(this);
this.useragent = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0';
this.language = 'en';
var url = 'http://front1.omegle.com';
var gotID = false;
var isConnected = false;
var _this = this;
var lastEvent = ''; //stopLookingForCommonLikes only works when this is set to 'waiting'.
var id = '';
var typing = false;
var challenge = ''; // to store recaptcha challenge.
var challengeLink = '';
//to check if the client is connected to the server
this.connected = function () {
return isConnected;
};
var randID = function () {
var charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
var str = '';
for (var i = 0; i < 8; ++i) str += charset.charAt(Math.floor((Math.random() * (charset.length + 1))));
return str;
};
var getResponse = function (path, data, callback, method = 'POST') {
var qsArr = ['/status', '/start']; //these paths use qs, others take urlencoded data.
var options = {
url: url + path,
headers: {
'User-Agent': this.useragent,
'Connection': 'keep-alive',
'Referer' : 'http://www.omegle.com',
'Origin' :'http://www.omegle.com',
'Host' : url,
'Referer': 'http://www.omegle.com',
'Origin': 'http://www.omegle.com',
'Host': url,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length' : 0
},
method: method
};
if (qsArr.indexOf(path)>-1)
{
options['qs'] = data;
'Content-Length': 0
},
method: method
};
if (qsArr.indexOf(path) > -1) {
options['qs'] = data;
}
else {
options.headers['Content-Length'] = qs.stringify(data).length;
options['form'] = qs.stringify(data);
}
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
return callback(body, null);
}
else
{
options.headers['Content-Length'] = qs.stringify(data).length;
options['form'] = qs.stringify(data);
else {
return callback(false, error);
}
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
return callback(body,null);
}
else
{
return callback(false,error);
}
});
});
};
this.connect = function (topics = false) {
this.updateServer();
var data = {
rcs: 1,
firstevents: 1,
lang: this.language,
randid: randID(),
spid: ''
};
if (topics) data['topics'] = formatTopics(topics);
getResponse('/start', data, function (body, error) {
if (body) {
id = JSON.parse(body).clientID;
gotID = true;
_this.emit('gotID', id);
emitEvents(JSON.parse(body).events);
_this.getEvents();
}
else _this.emit('omerror', 'connect(): ' + error);
});
};
var formatTopics = function (topicsArr) {
var top = '[';
for (var i = 0; i < topicsArr.length; ++i) top += '"' + topicsArr[i] + '",';
top = top.slice(0, -1);
top += ']';
return top;
};
this.getEvents = function () {
var data = {
id: id
};
if (!gotID && !isConnected) return;
getResponse('/events', data, function (events, error) {
if (events) {
var ev = JSON.parse(events);
emitEvents(ev);
if (gotID) _this.getEvents();
}
else {
_this.emit('omerror', 'getEvents(): ' + error);
if (gotID) _this.getEvents();
}
});
};
var emitEvents = function (ev) {
if (!ev) return;
var eventsArr = ['waiting', 'connected', 'error', 'connectionDied', 'antinudeBanned', 'typing',
'stoppedTyping', 'gotMessage', 'strangerDisconnected', 'recaptchaRequired',
'recaptchaRejected', 'commonLikes'];
for (var i = 0; i < ev.length; ++i) {
var currentEvent = ev[i][0];
if (eventsArr.indexOf(currentEvent) < 0) continue;
lastEvent = currentEvent;
if (currentEvent == 'waiting') _this.emit('waiting');
else if (currentEvent == 'connected') {
challengeLink = '';
challenge = '';
isConnected = true;
_this.emit('connected');
}
else if (currentEvent == 'error') {
reset();
_this.emit('omegleError', +ev[i][1]);
}
else if (currentEvent == 'connectionDied') {
reset();
_this.emit('connectionDied');
}
else if (currentEvent == 'antinudeBanned') {
reset();
_this.emit('antinudeBanned');
}
else if (currentEvent == 'typing') {
typing = true;
_this.emit('typing');
}
else if (currentEvent == 'stoppedTyping') _this.emit('stoppedTyping');
else if (currentEvent == 'gotMessage') {
if (typing) _this.emit('stoppedTyping');
for (var j = 1; j < ev[i].length; ++j) _this.emit('gotMessage', ev[i][j]);
}
else if (currentEvent == 'strangerDisconnected') {
reset();
_this.emit('strangerDisconnected');
}
else if (currentEvent == 'recaptchaRequired') evalCaptcha(ev[i][1]);
else if (currentEvent == 'recaptchaRejected') evalCaptcha(ev[i][1]);
else if (currentEvent == 'commonLikes') _this.emit('commonLikes', ev[i][1]);
}
this.connect=function(topics=false){
this.updateServer();
};
var evalCaptcha = function (pchallengeLink) {
challengeLink = pchallengeLink;
var url = 'http://www.google.com/recaptcha/api/challenge?k=' + pchallengeLink;
request.get(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
var close = body.indexOf('}');
//I give up. JSON.parse, you have failed me, or maybe I'm just dumb.
eval(body.substring(0, close + 1)); // jshint ignore:line
challenge = RecaptchaState.challenge; // jshint ignore:line
_this.emit('recaptchaRequired', 'http://www.google.com/recaptcha/api/image?c=' + challenge);
}
});
};
this.reloadReCAPTCHA = function () {
if (challengeLink) evalCaptcha(challengeLink);
};
this.updateServer = function () {
getResponse('/status', {
nocache: Math.random(),
randid: randID()
}, function (statusBody, error) {
if (statusBody) {
url = 'http://' + JSON.parse(statusBody).servers[0];
_this.emit('serverUpdated', url);
}
else {
_this.emit('omerror', 'updateServer(): ' + error);
}
}, 'GET');
};
this.send = function (msg) {
if (gotID && isConnected) {
var data = {
rcs: 1,
firstevents: 1,
lang: this.language,
randid: randID(),
spid:''
msg: msg,
id: id
};
if(topics)
data['topics'] =formatTopics(topics);
getResponse('/start',data, function(body,error){
if(body)
{
id=JSON.parse(body).clientID;
gotID = true;
_this.emit('gotID', id);
emitEvents(JSON.parse(body).events)
_this.getEvents();
getResponse('/send', data, function (body, error) {
if (body) {
if (body != 'win') _this.emit('omerror', 'send(): ' + body);
}
else
_this.emit('omerror', 'connect(): '+error);
else _this.emit('omerror', 'send(): ' + error);
});
}
var formatTopics = function(topicsArr){
var top = '[';
for(i=0;i<topicsArr.length;++i)
top+='"'+topicsArr[i]+'",'
top = top.slice(0,-1);
top+=']';
return top;
else {
_this.emit('omerror', 'send(): Not connected to ' + (gotID ? 'a stranger yet.' : 'the server.'));
}
this.getEvents=function(){
var data={id:id};
if(!gotID&&!isConnected)
return;
getResponse('/events',data, function(events,error){
if(events)
{
var ev = JSON.parse(events);
emitEvents(ev);
if(gotID)
_this.getEvents();
};
this.startTyping = function () {
if (gotID && isConnected) {
var data = {
id: id
};
getResponse('/typing', data, function (body, error) {
if (body) {
if (body != 'win') _this.emit('omerror', 'startTyping(): Couldn\'t send the typing event. Response from server: ' + body);
}
else
{
_this.emit('omerror', 'getEvents(): '+error);
if(gotID)
_this.getEvents();
else _this.emit('omerror', 'startTyping(): ' + error);
});
}
else _this.emit('omerror', 'startTyping(): Couldn\'t send the typing event. Not connected to ' + (gotID ? 'a stranger yet.' : 'the server.'));
};
this.stopTyping = function () {
if (gotID && isConnected) {
var data = {
id: id
};
getResponse('/stoppedtyping', data, function (body, error) {
if (body) {
if (body != 'win') _this.emit('omerror', 'stopTyping(): Couldn\'t send the stoppedtyping event. Response from server: ' + body);
}
else _this.emit('omerror', error);
});
}
var emitEvents = function(ev){
if(!ev)
return;
var eventsArr = ['waiting','connected','error','connectionDied','antinudeBanned','typing',
'stoppedTyping','gotMessage','strangerDisconnected','recaptchaRequired',
'recaptchaRejected','commonLikes'];
for(i=0;i<ev.length;++i)
{
var currentEvent = ev[i][0];
if(eventsArr.indexOf(currentEvent)<0)
continue;
lastEvent = currentEvent;
if(currentEvent=='waiting')
_this.emit('waiting');
else if(currentEvent=='connected')
{
challengeLink = '';
challenge = '';
isConnected = true;
_this.emit('connected');
else _this.emit('omerror', 'stopTyping(): Couldn\'t send the stoppedtyping event. Not connected to ' + (gotID ? 'a stranger yet.' : 'the server.'));
};
this.stopLookingForCommonLikes = function (callback) {
if (lastEvent == 'waiting' && !challengeLink) {
var data = {
id: id
};
getResponse('/stoplookingforcommonlikes', data, function (body, error) {
if (body) {
if (body != 'win') _this.emit('omerror', 'stopLookingForCommonLikes(): Something went wrong. Response from server: ' + body);
}
else if(currentEvent=='error')
{
else _this.emit('omerror', error);
if (callback) callback(body);
});
}
//else
// _this.emit('omerror','stopLookingForCommonLikes: ' + (isConnected?'Already connected to a stranger':'Current event is not \'waiting\'. Current event: '+lastEvent));
};
this.slfcl = this.stopLookingForCommonLikes;
this.disconnect = function () {
if (gotID && isConnected) {
var data = {
id: id
};
getResponse('/disconnect', data, function (body, error) {
if (body) {
if (body != 'win') _this.emit('omerror', 'disconnect(): Couldn\'t send the disconnect event. Response from server: ' + body);
reset();
_this.emit('omegleError', + ev[i][1]);
}
else if(currentEvent=='connectionDied')
{
reset();
_this.emit('connectionDied');
}
else if(currentEvent=='antinudeBanned')
{
reset();
_this.emit('antinudeBanned');
}
else if(currentEvent=='typing')
{
typing = true;
_this.emit('typing');
}
else if(currentEvent=='stoppedTyping')
_this.emit('stoppedTyping');
else if(currentEvent=='gotMessage')
{
if(typing)
_this.emit('stoppedTyping');
for(j = 1; j<ev[i].length; ++j)
_this.emit('gotMessage',ev[i][j]);
}
else if(currentEvent=='strangerDisconnected')
{
reset();
_this.emit('strangerDisconnected');
}
else if(currentEvent=='recaptchaRequired')
evalCaptcha(ev[i][1]);
else if(currentEvent=='recaptchaRejected')
evalCaptcha(ev[i][1]);
else if(currentEvent=='commonLikes')
_this.emit('commonLikes',ev[i][1]);
}
else _this.emit('omerror', 'disconnect(): ' + error);
});
}
var evalCaptcha = function(pchallengeLink){
challengeLink = pchallengeLink;
var url = 'http://www.google.com/recaptcha/api/challenge?k='+pchallengeLink;
request.get(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
var close = body.indexOf('}')
eval(body.substring(0,close+1)); //I give up. JSON.parse, you have failed me, or maybe I'm just dumb.
challenge = RecaptchaState.challenge;
_this.emit('recaptchaRequired','http://www.google.com/recaptcha/api/image?c='+challenge);
}
else _this.emit('omerror', 'disconnect(): Couldn\'t send the disconnect event. Not connected to ' + (gotID ? 'a stranger yet.' : 'the server.'));
};
// I haven't tested this, because I'd first have to get banned to be able to test this, but it should work.
// Nevermind, I got banned today, turns out I implemented recaptcha handling totally wrong. Now it's working.
this.solveReCAPTCHA = function (answer) {
if (gotID && challenge) {
var data = {
id: id,
challenge: challenge,
response: answer
};
getResponse('/recaptcha', data, function (body, error) {
if (error) _this.emit('omerror', 'solveReCAPTCHA(): ' + error);
});
}
this.reloadReCAPTCHA = function(){
if(challengeLink)
evalCaptcha(challengeLink)
}
this.updateServer=function(){
getResponse('/status',{nocache:Math.random(),randid:randID()},function(statusBody,error){
if(statusBody)
{
url='http://'+JSON.parse(statusBody).servers[0];
_this.emit('serverUpdated', url);
}
else
{
_this.emit('omerror', 'updateServer(): '+ error);
}
},'GET');
}
this.send = function(msg){
if(gotID&&isConnected)
{
var data={msg:msg,id:id};
getResponse('/send',data, function(body,error){
if(body)
{
if(body!='win')
_this.emit('omerror', 'send(): '+ body);
}
else
_this.emit('omerror', 'send(): '+error);
});
}
else
{
_this.emit('omerror', 'send(): Not connected to '+(gotID?'a stranger yet.':'the server.'));
}
}
this.startTyping = function(){
if(gotID&&isConnected)
{
var data={id:id};
getResponse('/typing',data, function(body,error){
if(body)
{
if(body!='win')
_this.emit('omerror', 'startTyping(): Couldn\'t send the typing event. Response from server: '+ body);
}
else
_this.emit('omerror', 'startTyping(): '+error);
});
}
else
_this.emit('omerror', 'startTyping(): Couldn\'t send the typing event. Not connected to '+(gotID?'a stranger yet.':'the server.'));
}
this.stopTyping = function(){
if(gotID&&isConnected)
{
var data={id:id};
getResponse('/stoppedtyping',data, function(body,error){
if(body)
{
if(body!='win')
_this.emit('omerror', 'stopTyping(): Couldn\'t send the stoppedtyping event. Response from server: '+ body);
}
else
_this.emit('omerror', error);
});
}
else
_this.emit('omerror', 'stopTyping(): Couldn\'t send the stoppedtyping event. Not connected to '+(gotID?'a stranger yet.':'the server.'));
}
this.stopLookingForCommonLikes = function(callback){
if(lastEvent=='waiting'&&!challengeLink)
{
var data={id:id};
getResponse('/stoplookingforcommonlikes',data, function(body,error){
if(body)
{
if(body!='win')
_this.emit('omerror', 'stopLookingForCommonLikes(): Something went wrong. Response from server: '+ body);
}
else
_this.emit('omerror', error);
if(callback)
callback(body);
});
}
//else
// _this.emit('omerror','stopLookingForCommonLikes: ' + (isConnected?'Already connected to a stranger':'Current event is not \'waiting\'. Current event: '+lastEvent));
}
this.slfcl = this.stopLookingForCommonLikes;
this.disconnect = function(){
if(gotID&&isConnected)
{
var data={id:id};
getResponse('/disconnect',data, function(body,error){
if(body)
{
if(body!='win')
_this.emit('omerror', 'disconnect(): Couldn\'t send the disconnect event. Response from server: '+ body);
reset();
}
else
_this.emit('omerror', 'disconnect(): '+error);
});
}
else
_this.emit('omerror', 'disconnect(): Couldn\'t send the disconnect event. Not connected to '+(gotID?'a stranger yet.':'the server.'));
}
// I haven't tested this, because I'd first have to get banned to be able to test this, but it should work.
// Nevermind, I got banned today, turns out I implemented recaptcha handling totally wrong. Now it's working.
this.solveReCAPTCHA = function(answer){
if(gotID&&challenge)
{
var data={
id:id,
challenge:challenge,
response:answer
};
getResponse('/recaptcha',data, function(body,error){
if(error)
_this.emit('omerror', 'solveReCAPTCHA(): '+error);
});
}
else
_this.emit('omerror', 'solveReCAPTCHA(): Not connected to the server or there\'s no ReCAPTCHA.');
}
var reset = function(){
isConnected = false;
gotID = false;
lastEvent = '';
id='';
typing = false;
challenge = '';
_this.emit('disconnected');
}
//TODO: Chat log support
}
else _this.emit('omerror', 'solveReCAPTCHA(): Not connected to the server or there\'s no ReCAPTCHA.');
};
var reset = function () {
isConnected = false;
gotID = false;
lastEvent = '';
id = '';
typing = false;
challenge = '';
_this.emit('disconnected');
};
//TODO: Chat log support
};
util.inherits(Omegle, ee);
module.exports = Omegle;
{
"name": "omegle-node",
"version": "1.1.1",
"version": "1.1.2",
"description": "Node.js API for Omegle",

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

# omegle-node - Unofficial node.js API for Omegle
[![NPM](https://nodei.co/npm/omegle-node.png)](https://npmjs.org/package/omegle-node)
[![npm version](https://badge.fury.io/js/omegle-node.png)](https://badge.fury.io/js/omegle-node)
omegle-node is an unofficial API for Omegle which can be used to connect and interact with people on omegle without actually going to the website.

@@ -38,2 +42,4 @@

- **`disconnected`**: emitted when you disconnect from the chat. This will be emitted when you call `disconnect()`. If you want to reconnect, call `connect()` again only `on` `disconnected` and `strangerDisconnected` event.
- **`strangerDisconnected`**: emitted when the stranger disconnects.

@@ -40,0 +46,0 @@

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