alicezetion 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"nonce":8394449526511183401,"last_updated":{"seconds":1693574365,"nanos":509516000}}
1
+ {"nonce":6648553304835487638,"last_updated":{"seconds":1693575670,"nanos":837574000}}
package/index.js CHANGED
@@ -66,67 +66,50 @@ function setOptions(globalOptions, options) {
66
66
  globalOptions.emitReady = Boolean(options.emitReady);
67
67
  break;
68
68
  default:
69
- log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
69
+ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
70
70
  break;
71
71
  }
72
72
  });
73
73
  }
74
+
75
+ function buildAPI(globalOptions, html, jar) {
76
+ try {
77
+ var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) {
78
+ return val.cookieString().split("=")[0] === "c_user";
79
+ });
80
+ if (maybeCookie.length === 0) throw { error: "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify." };
81
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
82
+ var userID = maybeCookie[0].cookieString().split("=")[1].toString();
83
+ clearInterval(checkVerified);
84
+ var clientID = (Math.random() * 2147483648 | 0).toString(16);
85
+ let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
86
+ let mqttEndpoint = null;
87
+ let region = null;
88
+ let irisSeqID = null;
89
+ var noMqttData = null;
90
+ if (oldFBMQTTMatch) {
91
+ irisSeqID = oldFBMQTTMatch[1];
92
+ mqttEndpoint = oldFBMQTTMatch[2];
93
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
94
+ } else {
95
+ let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
96
+ if (newFBMQTTMatch) {
97
+ irisSeqID = newFBMQTTMatch[2];
98
+ mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
99
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
100
+ } else {
101
+ let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
102
+ if (legacyFBMQTTMatch) {
103
+ mqttEndpoint = legacyFBMQTTMatch[4];
104
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
105
+ } else {
106
+ noMqttData = html;
107
+ process.exit();
108
+ }
109
+ }
110
+ }
111
+ } catch (err) {}
74
112
 
75
- function buildAPI(globalOptions, html, jar) {
76
- var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function (val) {
77
- return val.cookieString().split("=")[0] === "c_user";
78
- });
79
-
80
- if (maybeCookie.length === 0) {
81
- throw { error: "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify." };
82
- }
83
-
84
- if (html.indexOf("/checkpoint/block/?next") > -1) {
85
- log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
86
- }
87
-
88
- var userID = maybeCookie[0].cookieString().split("=")[1].toString();
89
- try {
90
- clearInterval(checkVerified);
91
- } catch (_) { }
92
-
93
- var clientID = (Math.random() * 2147483648 | 0).toString(16);
94
-
95
-
96
- let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
97
- let mqttEndpoint = null;
98
- let region = null;
99
- let irisSeqID = null;
100
- var noMqttData = null;
101
-
102
- if (oldFBMQTTMatch) {
103
- irisSeqID = oldFBMQTTMatch[1];
104
- mqttEndpoint = oldFBMQTTMatch[2];
105
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
106
- //log.info("login", `Got this account's message region: ${region}`);
107
- } else {
108
- let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
109
- if (newFBMQTTMatch) {
110
- irisSeqID = newFBMQTTMatch[2];
111
- mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
112
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
113
- // log.info("login", `Got this account's message region: ${region}`);
114
- } else {
115
- let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
116
- if (legacyFBMQTTMatch) {
117
- mqttEndpoint = legacyFBMQTTMatch[4];
118
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
119
- /* log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
120
- log.info("login", `Got this account's message region: ${region}`);
121
- log.info("login", `[Unused] Polling endpoint: ${legacyFBMQTTMatch[6]}`);*/
122
- } else {
123
- log.warn("login", "Cannot get MQTT region & sequence ID.");
124
- noMqttData = html;
125
- }
126
- }
127
- }
128
-
129
- // All data available to api functions
130
113
  var ctx = {
131
114
  userID: userID,
132
115
  jar: jar,
@@ -214,10 +197,6 @@ function buildAPI(globalOptions, html, jar) {
214
197
  api[v] = require('./leiamnash/' + v)(defaultFuncs, api, ctx);
215
198
  });
216
199
 
217
- //Removing original `listen` that uses pull.
218
- //Map it to listenMqtt instead for backward compatibly.
219
- api.listen = api.listenMqtt;
220
-
221
200
  return [ctx, defaultFuncs, api];
222
201
  }
223
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint **.js",