alicezetion 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"nonce":8394449526511183401,"last_updated":{"seconds":1693574365,"nanos":509516000}}
1
+ {"nonce":5642102250332360091,"last_updated":{"seconds":1693575920,"nanos":837442000}}
package/index.js CHANGED
@@ -66,83 +66,66 @@ 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
- 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
- var ctx = {
131
- userID: userID,
132
- jar: jar,
133
- clientID: clientID,
134
- globalOptions: globalOptions,
135
- loggedIn: true,
136
- access_token: 'NONE',
137
- clientMutationId: 0,
138
- mqttClient: undefined,
139
- lastSeqId: irisSeqID,
140
- syncToken: undefined,
141
- mqttEndpoint,
142
- region,
143
- firstListen: true
144
- };
145
-
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) {}
112
+
113
+ var ctx = {
114
+ userID: userID,
115
+ jar: jar,
116
+ clientID: clientID,
117
+ globalOptions: globalOptions,
118
+ loggedIn: true,
119
+ access_token: 'NONE',
120
+ clientMutationId: 0,
121
+ mqttClient: undefined,
122
+ lastSeqId: irisSeqID,
123
+ syncToken: undefined,
124
+ mqttEndpoint,
125
+ region,
126
+ firstListen: true
127
+ };
128
+
146
129
  var api = {
147
130
  setOptions: setOptions.bind(null, globalOptions),
148
131
  getAppState: function getAppState() {
@@ -150,9 +133,7 @@ function buildAPI(globalOptions, html, jar) {
150
133
  }
151
134
  };
152
135
 
153
- if (noMqttData) {
154
- api["htmlData"] = noMqttData;
155
- }
136
+ if (noMqttData) api["htmlData"] = noMqttData;
156
137
 
157
138
  const apiFuncNames = [
158
139
  'addExternalModule',
@@ -214,10 +195,6 @@ function buildAPI(globalOptions, html, jar) {
214
195
  api[v] = require('./leiamnash/' + v)(defaultFuncs, api, ctx);
215
196
  });
216
197
 
217
- //Removing original `listen` that uses pull.
218
- //Map it to listenMqtt instead for backward compatibly.
219
- api.listen = api.listenMqtt;
220
-
221
198
  return [ctx, defaultFuncs, api];
222
199
  }
223
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint **.js",