Socket
Socket
Sign inDemoInstall

fca-unofficial

Package Overview
Dependencies
6
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.0.6

2

DOCS.md

@@ -1637,3 +1637,2 @@ # Documentation

- `listenEvents`: (Default `false`) Will make [api.listen](#listen) also handle events (look at api.listen for more details).
- `listenEvents`: (Default `false`) Will make [api.listen](#listen) also handle typing events (look at api.listen for more details).
- `pageID`: (Default empty) Makes [api.listen](#listen) only receive messages through the page specified by that ID. Also makes [api.sendMessage](#sendMessage) send from the page.

@@ -1645,2 +1644,3 @@ - `updatePresence`: (Default `false`) Will make [api.listen](#listen) also return `presence` ([api.listen](#presence) for more details).

- `autoMarkRead`: (Default `false`) Will automatically mark new messages as read/seen. See [api.markAsRead](#markAsRead).
- `proxy`: (Default empty) Set this to proxy server address to use proxy. Note: Only HTTP Proxies which support CONNECT method is supported.

@@ -1647,0 +1647,0 @@ __Example__

@@ -48,2 +48,11 @@ "use strict";

break;
case 'proxy':
if (typeof options.proxy == "undefined") {
delete globalOptions.proxy;
utils.setProxy();
} else {
globalOptions.proxy = options.proxy;
utils.setProxy(globalOptions.proxy);
}
break;
default:

@@ -50,0 +59,0 @@ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);

{
"name": "fca-unofficial",
"version": "1.0.5",
"version": "1.0.6",
"description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.",

@@ -27,2 +27,3 @@ "scripts": {

"cheerio": "^0.22.0",
"https-proxy-agent": "^4.0.0",
"mqtt": "^3.0.0",

@@ -29,0 +30,0 @@ "npmlog": "^1.2.0",

@@ -251,3 +251,3 @@ This repo is a fork from main repo and will usually have new features bundled faster than main repo (and maybe bundle some bugs, too).

- [facebot](https://github.com/Weetbix/facebot) - A facebook bridge for Slack.
- [TestMyBot](https://github.com/codeforequity-at/testmybot) - Test Automation Framework for Chatbots
- [Botium](https://github.com/codeforequity-at/botium-core) - The Selenium for Chatbots
- [Messenger-CLI](https://github.com/AstroCB/Messenger-CLI) - A command-line interface for sending and receiving messages through Facebook Messenger.

@@ -254,0 +254,0 @@ - [AssumeZero-Bot](https://github.com/AstroCB/AssumeZero-Bot) – A highly customizable Facebook Messenger bot for group chats.

@@ -6,7 +6,33 @@ /* eslint-disable no-redeclare */

var log = require("npmlog");
var HttpsProxyAgent = require('https-proxy-agent');
var identity = function () { };
var identity = function () {};
var mqttClient = undefined;
var lastSeqId = 0;
var client = undefined;
var syncToken;
//Don't really know what this does but I think it's for the active state
var chatOn = true;
var foreground = false;
var topics = [
"/t_ms",
"/thread_typing",
"/orca_typing_notifications",
"/orca_presence",
"/legacy_web",
"/br_sr",
"/sr_res",
"/webrtc",
"/onevc",
"/notify_disconnect",
"/inbox",
"/mercury",
"/messaging_events",
"/orca_message_notifications",
"/pp",
"/webrtc_response",
];
function listenMqtt(defaultFuncs, api, ctx, globalCallback) {

@@ -17,12 +43,12 @@ var sessionID = Math.floor(Math.random() * 9007199254740991) + 1;

s: sessionID,
cp: 3,
ecp: 10,
chat_on: true,
fg: false,
chat_on: chatOn,
fg: foreground,
d: utils.getGUID(),
ct: "websocket",
mqtt_sid: "",
//App id from facebook
aid: "219994525426954",
st: [],
mqtt_sid: "",
cp: 3,
ecp: 10,
st: topics,
pm: [],

@@ -35,5 +61,5 @@ dc: "",

//Region could be changed for better ping. (Region atn: Southeast Asia, region ash: West US, prob)
//Region
var host = 'wss://edge-chat.facebook.com/chat?region=atn&sid=' + sessionID;
//Region could be changed for better ping. (Region atn: Southeast Asia, region ash: West US, prob) (Don't really know if we need it).
//// var host = 'wss://edge-chat.facebook.com/chat?region=atn&sid=' + sessionID;
var host = 'wss://edge-chat.facebook.com/chat?sid=' + sessionID;

@@ -45,2 +71,3 @@ var options = {

username: JSON.stringify(username),
clean: true,
wsOptions: {

@@ -52,2 +79,3 @@ 'headers': {

'Referer': 'https://www.facebook.com',
'Host': 'edge-chat.facebook.com'
},

@@ -59,42 +87,48 @@ origin: 'https://www.facebook.com',

client = fbconnect.connect(host, options);
if (typeof ctx.globalOptions.proxy != "undefined") {
var agent = new HttpsProxyAgent(ctx.globalOptions.proxy);
options.wsOptions.agent = agent;
}
client.on('error', function (err) {
mqttClient = fbconnect.connect(host, options);
mqttClient.on('error', function(err) {
log.error(err);
client.end();
mqttClient.end();
globalCallback("Connection refused: Server unavailable", null);
});
client.on('connect', function () {
var subscribelist = ["/t_ms"];
ctx.globalOptions.updatePresence ? subscribelist.push("/orca_presence") : "";
ctx.globalOptions.listenTyping ? subscribelist.push("/thread_typing", "/orca_typing_notifications") : "";
//client.subscribe(["/legacy_web", "/webrtc", "/br_sr", "/sr_res", "/thread_typing", "/orca_typing_notifications", "/notify_disconnect", "/orca_presence"],
client.subscribe(subscribelist,
(_err, _granted) => {
client.unsubscribe('/orca_message_notifications', (_err) => {
var queue = {
sync_api_version: 10,
max_deltas_able_to_process: 1000,
delta_batch_size: 500,
encoding: "JSON",
entity_fbid: ctx.userID,
initial_titan_sequence_id: lastSeqId,
device_params: null
};
mqttClient.on('connect', function() {
var topic;
var queue = {
sync_api_version: 10,
max_deltas_able_to_process: 1000,
delta_batch_size: 500,
encoding: "JSON",
entity_fbid: ctx.userID,
};
client.publish('/messenger_sync_create_queue', JSON.stringify(queue), { qos: 0, retain: false });
});
});
if(syncToken) {
topic = "/messenger_sync_get_diffs";
queue.last_seq_id = lastSeqId;
queue.sync_token = syncToken;
} else {
topic = "/messenger_sync_create_queue";
queue.initial_titan_sequence_id = lastSeqId;
queue.device_params = null;
}
mqttClient.publish(topic, JSON.stringify(queue), {qos: 1, retain: false});
});
client.on('message', function (topic, message, _packet) {
mqttClient.on('message', function(topic, message, _packet) {
var jsonMessage = JSON.parse(message);
if (topic === "/t_ms") {
if (jsonMessage.lastIssuedSeqId) {
if(topic === "/t_ms") {
if(jsonMessage.firstDeltaSeqId && jsonMessage.syncToken) {
lastSeqId = jsonMessage.firstDeltaSeqId;
syncToken = jsonMessage.syncToken;
}
if(jsonMessage.lastIssuedSeqId) {
lastSeqId = parseInt(jsonMessage.lastIssuedSeqId);
} else {
if (jsonMessage.deltas) {
lastSeqId = parseInt(jsonMessage.deltas[0].irisSeqId);
}
}

@@ -135,3 +169,3 @@

client.on('close', function () {
mqttClient.on('close', function() {
// client.end();

@@ -479,2 +513,4 @@ });

globalCallback = callback;
//Same request as getThreadList
const form = {

@@ -521,3 +557,3 @@ "av": ctx.globalOptions.pageID,

globalCallback = identity;
client.end();
mqttClient.end();
};

@@ -524,0 +560,0 @@

@@ -65,6 +65,6 @@ //From MQTT.js (https://github.com/mqttjs/MQTT.js)

if (opts.cert && opts.key) {
if (opts.protocol) {
if (['mqtts', 'wss'].indexOf(opts.protocol) === -1) {
switch (opts.protocol) {
if(opts.cert && opts.key) {
if(opts.protocol) {
if(['mqtts', 'wss'].indexOf(opts.protocol) === -1) {
switch(opts.protocol) {
case 'mqtt':

@@ -93,4 +93,4 @@ opts.protocol = 'mqtts';

'wss'
].filter(function (key, index) {
if (isSecure && index % 2 === 0) {
].filter(function(key, index) {
if(isSecure && index % 2 === 0) {
// Skip insecure protocols when requesting a secure one.

@@ -97,0 +97,0 @@ return false;

@@ -8,2 +8,13 @@ "use strict";

function setProxy(url) {
if (typeof url == undefined)
return request = bluebird.promisify(require("request").defaults({
jar: true,
}));
return request = bluebird.promisify(require("request").defaults({
jar: true,
proxy: url
}));
}
function getHeaders(url, options) {

@@ -187,2 +198,3 @@ var headers = {

// eslint-disable-next-line no-unused-vars
function presenceDecode(str) {

@@ -1281,4 +1293,5 @@ return decodeURIComponent(

getAppState,
getAdminTextMessageType
getAdminTextMessageType,
setProxy
};
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc