capfb 0.0.1-security → 1.3.20-test

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of capfb might be problematic. Click here for more details.

Files changed (77) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/nodejs.yml +26 -0
  4. package/.github/workflows/npmpublish.yml +30 -0
  5. package/CHANGELOG.md +2 -0
  6. package/DOCS.md +1738 -0
  7. package/Extra/Database/index.js +399 -0
  8. package/Extra/Database/methods.js +286 -0
  9. package/Extra/ExtraAddons.js +78 -0
  10. package/Extra/ExtraAddonsDeprecated.js +213 -0
  11. package/Extra/ExtraGetThread.js +1 -0
  12. package/Extra/ExtraUptimeRobot.js +59 -0
  13. package/Extra/PM2/ecosystem.config.js +23 -0
  14. package/Extra/Src/Last-Run.js +48 -0
  15. package/LICENSE-MIT +21 -0
  16. package/Language/index.json +151 -0
  17. package/README.md +225 -3
  18. package/StateCrypt.js +22 -0
  19. package/broadcast.js +42 -0
  20. package/index-backup.js +1079 -0
  21. package/index.js +1089 -0
  22. package/logger.js +21 -0
  23. package/package.json +88 -3
  24. package/src/addExternalModule.js +16 -0
  25. package/src/addUserToGroup.js +78 -0
  26. package/src/changeAdminStatus.js +79 -0
  27. package/src/changeArchivedStatus.js +41 -0
  28. package/src/changeBio.js +65 -0
  29. package/src/changeBlockedStatus.js +36 -0
  30. package/src/changeGroupImage.js +106 -0
  31. package/src/changeNickname.js +45 -0
  32. package/src/changeThreadColor.js +62 -0
  33. package/src/changeThreadEmoji.js +42 -0
  34. package/src/createNewGroup.js +70 -0
  35. package/src/createPoll.js +60 -0
  36. package/src/deleteMessage.js +45 -0
  37. package/src/deleteThread.js +43 -0
  38. package/src/forwardAttachment.js +48 -0
  39. package/src/getAccessToken.js +31 -0
  40. package/src/getCurrentUserID.js +7 -0
  41. package/src/getEmojiUrl.js +27 -0
  42. package/src/getFriendsList.js +73 -0
  43. package/src/getMessage.js +80 -0
  44. package/src/getThreadHistory.js +537 -0
  45. package/src/getThreadHistoryDeprecated.js +71 -0
  46. package/src/getThreadInfo.js +197 -0
  47. package/src/getThreadInfoDeprecated.js +56 -0
  48. package/src/getThreadList.js +213 -0
  49. package/src/getThreadListDeprecated.js +46 -0
  50. package/src/getThreadPictures.js +59 -0
  51. package/src/getUserID.js +62 -0
  52. package/src/getUserInfo.js +65 -0
  53. package/src/getUserInfoV2.js +35 -0
  54. package/src/handleFriendRequest.js +46 -0
  55. package/src/handleMessageRequest.js +49 -0
  56. package/src/httpGet.js +49 -0
  57. package/src/httpPost.js +48 -0
  58. package/src/httpPostFormData.js +41 -0
  59. package/src/listenMqtt.js +633 -0
  60. package/src/logout.js +68 -0
  61. package/src/markAsDelivered.js +48 -0
  62. package/src/markAsRead.js +70 -0
  63. package/src/markAsReadAll.js +43 -0
  64. package/src/markAsSeen.js +51 -0
  65. package/src/muteThread.js +47 -0
  66. package/src/removeUserFromGroup.js +49 -0
  67. package/src/resolvePhotoUrl.js +37 -0
  68. package/src/searchForThread.js +43 -0
  69. package/src/sendMessage.js +342 -0
  70. package/src/sendTypingIndicator.js +80 -0
  71. package/src/setMessageReaction.js +109 -0
  72. package/src/setPostReaction.js +102 -0
  73. package/src/setTitle.js +74 -0
  74. package/src/threadColors.js +39 -0
  75. package/src/unfriend.js +43 -0
  76. package/src/unsendMessage.js +40 -0
  77. package/utils.js +1244 -0
package/utils.js ADDED
@@ -0,0 +1,1244 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable no-prototype-builtins */
3
+ "use strict";
4
+
5
+ const bluebird = require("bluebird");
6
+ var request = bluebird.promisify(require("request").defaults({ jar: true }));
7
+ var stream = require("stream");
8
+ var log = require("npmlog");
9
+ var querystring = require("querystring");
10
+ var url = require("url");
11
+
12
+ function setProxy(url) {
13
+ if (typeof url == undefined) return request = bluebird.promisify(require("request").defaults({ jar: true }));
14
+ return request = bluebird.promisify(require("request").defaults({ jar: true, proxy: url }));
15
+ }
16
+
17
+ function getHeaders(url, options, ctx, customHeader) {
18
+ var headers = {
19
+ "Content-Type": "application/x-www-form-urlencoded",
20
+ Referer: "https://www.facebook.com/",
21
+ Host: url.replace("https://", "").split("/")[0],
22
+ Origin: "https://www.facebook.com",
23
+ "User-Agent": options.userAgent,
24
+ Connection: "keep-alive",
25
+ 'sec-fetch-site': 'same-origin'
26
+ };
27
+ if (customHeader) Object.assign(headers, customHeader);
28
+
29
+ if (ctx && ctx.region) headers["X-MSGR-Region"] = ctx.region;
30
+
31
+ return headers;
32
+ }
33
+
34
+ function isReadableStream(obj) {
35
+ return (
36
+ obj instanceof stream.Stream &&
37
+ (getType(obj._read) === "Function" ||
38
+ getType(obj._read) === "AsyncFunction") &&
39
+ getType(obj._readableState) === "Object"
40
+ );
41
+ }
42
+
43
+ function get(url, jar, qs, options, ctx) {
44
+ // I'm still confused about this
45
+ if (getType(qs) === "Object")
46
+ for (var prop in qs)
47
+ if (qs.hasOwnProperty(prop) && getType(qs[prop]) === "Object") qs[prop] = JSON.stringify(qs[prop]);
48
+ var op = {
49
+ headers: getHeaders(url, options, ctx),
50
+ timeout: 60000,
51
+ qs: qs,
52
+ url: url,
53
+ method: "GET",
54
+ jar: jar,
55
+ gzip: true
56
+ };
57
+
58
+ return request(op).then(function(res) {
59
+ return res[0];
60
+ });
61
+ }
62
+
63
+ function post(url, jar, form, options, ctx, customHeader) {
64
+ let headers = getHeaders(url, options);
65
+ headers['sec-fetch-site'] = 'same-origin';
66
+ var op = {
67
+ headers: headers,
68
+ timeout: 60000,
69
+ url: url,
70
+ method: "POST",
71
+ form: form,
72
+ jar: jar,
73
+ gzip: true
74
+ };
75
+
76
+ return request(op).then(function(res) {
77
+ return res[0];
78
+ });
79
+ }
80
+
81
+ function postFormData(url, jar, form, qs, options, ctx) {
82
+ var headers = getHeaders(url, options, ctx);
83
+ headers["Content-Type"] = "multipart/form-data";
84
+ var op = {
85
+ headers: headers,
86
+ timeout: 60000,
87
+ url: url,
88
+ method: "POST",
89
+ formData: form,
90
+ qs: qs,
91
+ jar: jar,
92
+ gzip: true
93
+ };
94
+
95
+ return request(op).then(function(res) {
96
+ return res[0];
97
+ });
98
+ }
99
+
100
+ function padZeros(val, len) {
101
+ val = String(val);
102
+ len = len || 2;
103
+ while (val.length < len) val = "0" + val;
104
+ return val;
105
+ }
106
+
107
+ function generateThreadingID(clientID) {
108
+ var k = Date.now();
109
+ var l = Math.floor(Math.random() * 4294967295);
110
+ var m = clientID;
111
+ return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
112
+ }
113
+
114
+ function binaryToDecimal(data) {
115
+ var ret = "";
116
+ while (data !== "0") {
117
+ var end = 0;
118
+ var fullName = "";
119
+ var i = 0;
120
+ for (; i < data.length; i++) {
121
+ end = 2 * end + parseInt(data[i], 10);
122
+ if (end >= 10) {
123
+ fullName += "1";
124
+ end -= 10;
125
+ } else fullName += "0";
126
+ }
127
+ ret = end.toString() + ret;
128
+ data = fullName.slice(fullName.indexOf("1"));
129
+ }
130
+ return ret;
131
+ }
132
+
133
+ function generateOfflineThreadingID() {
134
+ var ret = Date.now();
135
+ var value = Math.floor(Math.random() * 4294967295);
136
+ var str = ("0000000000000000000000" + value.toString(2)).slice(-22);
137
+ var msgs = ret.toString(2) + str;
138
+ return binaryToDecimal(msgs);
139
+ }
140
+
141
+ var h;
142
+ var i = {};
143
+ var j = {
144
+ _: "%",
145
+ A: "%2",
146
+ B: "000",
147
+ C: "%7d",
148
+ D: "%7b%22",
149
+ E: "%2c%22",
150
+ F: "%22%3a",
151
+ G: "%2c%22ut%22%3a1",
152
+ H: "%2c%22bls%22%3a",
153
+ I: "%2c%22n%22%3a%22%",
154
+ J: "%22%3a%7b%22i%22%3a0%7d",
155
+ K: "%2c%22pt%22%3a0%2c%22vis%22%3a",
156
+ L: "%2c%22ch%22%3a%7b%22h%22%3a%22",
157
+ M: "%7b%22v%22%3a2%2c%22time%22%3a1",
158
+ N: ".channel%22%2c%22sub%22%3a%5b",
159
+ O: "%2c%22sb%22%3a1%2c%22t%22%3a%5b",
160
+ P: "%2c%22ud%22%3a100%2c%22lc%22%3a0",
161
+ Q: "%5d%2c%22f%22%3anull%2c%22uct%22%3a",
162
+ R: ".channel%22%2c%22sub%22%3a%5b1%5d",
163
+ S: "%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",
164
+ T: "%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",
165
+ U: "%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
166
+ V: "%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",
167
+ W: "%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
168
+ X: "%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",
169
+ Y: "%2c%22pt%22%3a0%2c%22vis%22%3a1%2c%22bls%22%3a0%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
170
+ Z: "%2c%22sb%22%3a1%2c%22t%22%3a%5b%5d%2c%22f%22%3anull%2c%22uct%22%3a0%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a"
171
+ };
172
+ (function() {
173
+ var l = [];
174
+ for (var m in j) {
175
+ i[j[m]] = m;
176
+ l.push(j[m]);
177
+ }
178
+ l.reverse();
179
+ h = new RegExp(l.join("|"), "g");
180
+ })();
181
+
182
+ function presenceEncode(str) {
183
+ return encodeURIComponent(str)
184
+ .replace(/([_A-Z])|%../g, function(m, n) {
185
+ return n ? "%" + n.charCodeAt(0).toString(16) : m;
186
+ })
187
+ .toLowerCase()
188
+ .replace(h, function(m) {
189
+ return i[m];
190
+ });
191
+ }
192
+
193
+ // eslint-disable-next-line no-unused-vars
194
+ function presenceDecode(str) {
195
+ return decodeURIComponent(
196
+ str.replace(/[_A-Z]/g, function(m) {
197
+ return j[m];
198
+ })
199
+ );
200
+ }
201
+
202
+ function generatePresence(userID) {
203
+ var time = Date.now();
204
+ return (
205
+ "E" +
206
+ presenceEncode(
207
+ JSON.stringify({
208
+ v: 3,
209
+ time: parseInt(time / 1000, 10),
210
+ user: userID,
211
+ state: {
212
+ ut: 0,
213
+ t2: [],
214
+ lm2: null,
215
+ uct2: time,
216
+ tr: null,
217
+ tw: Math.floor(Math.random() * 4294967295) + 1,
218
+ at: time
219
+ },
220
+ ch: {
221
+ ["p_" + userID]: 0
222
+ }
223
+ })
224
+ )
225
+ );
226
+ }
227
+
228
+ function generateAccessiblityCookie() {
229
+ var time = Date.now();
230
+ return encodeURIComponent(
231
+ JSON.stringify({
232
+ sr: 0,
233
+ "sr-ts": time,
234
+ jk: 0,
235
+ "jk-ts": time,
236
+ kb: 0,
237
+ "kb-ts": time,
238
+ hcm: 0,
239
+ "hcm-ts": time
240
+ })
241
+ );
242
+ }
243
+
244
+ function getGUID() {
245
+ /** @type {number} */
246
+ var sectionLength = Date.now();
247
+ /** @type {string} */
248
+ var id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
249
+ /** @type {number} */
250
+ var r = Math.floor((sectionLength + Math.random() * 16) % 16);
251
+ /** @type {number} */
252
+ sectionLength = Math.floor(sectionLength / 16);
253
+ /** @type {string} */
254
+ var _guid = (c == "x" ? r : (r & 7) | 8).toString(16);
255
+ return _guid;
256
+ });
257
+ return id;
258
+ }
259
+
260
+ function _formatAttachment(attachment1, attachment2) {
261
+ // TODO: THIS IS REALLY BAD
262
+ // This is an attempt at fixing Facebook's inconsistencies. Sometimes they give us
263
+ // two attachment objects, but sometimes only one. They each contain part of the
264
+ // data that you'd want so we merge them for convenience.
265
+ // Instead of having a bunch of if statements guarding every access to image_data,
266
+ // we set it to empty object and use the fact that it'll return undefined.
267
+ attachment2 = attachment2 || { id: "", image_data: {} };
268
+ attachment1 = attachment1.mercury ? attachment1.mercury : attachment1;
269
+ var blob = attachment1.blob_attachment;
270
+ var type =
271
+ blob && blob.__typename ? blob.__typename : attachment1.attach_type;
272
+ if (!type && attachment1.sticker_attachment) {
273
+ type = "StickerAttachment";
274
+ blob = attachment1.sticker_attachment;
275
+ } else if (!type && attachment1.extensible_attachment) {
276
+ if (
277
+ attachment1.extensible_attachment.story_attachment &&
278
+ attachment1.extensible_attachment.story_attachment.target &&
279
+ attachment1.extensible_attachment.story_attachment.target.__typename &&
280
+ attachment1.extensible_attachment.story_attachment.target.__typename === "MessageLocation"
281
+ ) type = "MessageLocation";
282
+ else type = "ExtensibleAttachment";
283
+
284
+ blob = attachment1.extensible_attachment;
285
+ }
286
+ // TODO: Determine whether "sticker", "photo", "file" etc are still used
287
+ // KEEP IN SYNC WITH getThreadHistory
288
+ switch (type) {
289
+ case "sticker":
290
+ return {
291
+ type: "sticker",
292
+ ID: attachment1.metadata.stickerID.toString(),
293
+ url: attachment1.url,
294
+
295
+ packID: attachment1.metadata.packID.toString(),
296
+ spriteUrl: attachment1.metadata.spriteURI,
297
+ spriteUrl2x: attachment1.metadata.spriteURI2x,
298
+ width: attachment1.metadata.width,
299
+ height: attachment1.metadata.height,
300
+
301
+ caption: attachment2.caption,
302
+ description: attachment2.description,
303
+
304
+ frameCount: attachment1.metadata.frameCount,
305
+ frameRate: attachment1.metadata.frameRate,
306
+ framesPerRow: attachment1.metadata.framesPerRow,
307
+ framesPerCol: attachment1.metadata.framesPerCol,
308
+
309
+ stickerID: attachment1.metadata.stickerID.toString(), // @Legacy
310
+ spriteURI: attachment1.metadata.spriteURI, // @Legacy
311
+ spriteURI2x: attachment1.metadata.spriteURI2x // @Legacy
312
+ };
313
+ case "file":
314
+ return {
315
+ type: "file",
316
+ filename: attachment1.name,
317
+ ID: attachment2.id.toString(),
318
+ url: attachment1.url,
319
+
320
+ isMalicious: attachment2.is_malicious,
321
+ contentType: attachment2.mime_type,
322
+
323
+ name: attachment1.name, // @Legacy
324
+ mimeType: attachment2.mime_type, // @Legacy
325
+ fileSize: attachment2.file_size // @Legacy
326
+ };
327
+ case "photo":
328
+ return {
329
+ type: "photo",
330
+ ID: attachment1.metadata.fbid.toString(),
331
+ filename: attachment1.fileName,
332
+ thumbnailUrl: attachment1.thumbnail_url,
333
+
334
+ previewUrl: attachment1.preview_url,
335
+ previewWidth: attachment1.preview_width,
336
+ previewHeight: attachment1.preview_height,
337
+
338
+ largePreviewUrl: attachment1.large_preview_url,
339
+ largePreviewWidth: attachment1.large_preview_width,
340
+ largePreviewHeight: attachment1.large_preview_height,
341
+
342
+ url: attachment1.metadata.url, // @Legacy
343
+ width: attachment1.metadata.dimensions.split(",")[0], // @Legacy
344
+ height: attachment1.metadata.dimensions.split(",")[1], // @Legacy
345
+ name: attachment1.fileName // @Legacy
346
+ };
347
+ case "animated_image":
348
+ return {
349
+ type: "animated_image",
350
+ ID: attachment2.id.toString(),
351
+ filename: attachment2.filename,
352
+
353
+ previewUrl: attachment1.preview_url,
354
+ previewWidth: attachment1.preview_width,
355
+ previewHeight: attachment1.preview_height,
356
+
357
+ url: attachment2.image_data.url,
358
+ width: attachment2.image_data.width,
359
+ height: attachment2.image_data.height,
360
+
361
+ name: attachment1.name, // @Legacy
362
+ facebookUrl: attachment1.url, // @Legacy
363
+ thumbnailUrl: attachment1.thumbnail_url, // @Legacy
364
+ mimeType: attachment2.mime_type, // @Legacy
365
+ rawGifImage: attachment2.image_data.raw_gif_image, // @Legacy
366
+ rawWebpImage: attachment2.image_data.raw_webp_image, // @Legacy
367
+ animatedGifUrl: attachment2.image_data.animated_gif_url, // @Legacy
368
+ animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url, // @Legacy
369
+ animatedWebpUrl: attachment2.image_data.animated_webp_url, // @Legacy
370
+ animatedWebpPreviewUrl: attachment2.image_data.animated_webp_preview_url // @Legacy
371
+ };
372
+ case "share":
373
+ return {
374
+ type: "share",
375
+ ID: attachment1.share.share_id.toString(),
376
+ url: attachment2.href,
377
+
378
+ title: attachment1.share.title,
379
+ description: attachment1.share.description,
380
+ source: attachment1.share.source,
381
+
382
+ image: attachment1.share.media.image,
383
+ width: attachment1.share.media.image_size.width,
384
+ height: attachment1.share.media.image_size.height,
385
+ playable: attachment1.share.media.playable,
386
+ duration: attachment1.share.media.duration,
387
+
388
+ subattachments: attachment1.share.subattachments,
389
+ properties: {},
390
+
391
+ animatedImageSize: attachment1.share.media.animated_image_size, // @Legacy
392
+ facebookUrl: attachment1.share.uri, // @Legacy
393
+ target: attachment1.share.target, // @Legacy
394
+ styleList: attachment1.share.style_list // @Legacy
395
+ };
396
+ case "video":
397
+ return {
398
+ type: "video",
399
+ ID: attachment1.metadata.fbid.toString(),
400
+ filename: attachment1.name,
401
+
402
+ previewUrl: attachment1.preview_url,
403
+ previewWidth: attachment1.preview_width,
404
+ previewHeight: attachment1.preview_height,
405
+
406
+ url: attachment1.url,
407
+ width: attachment1.metadata.dimensions.width,
408
+ height: attachment1.metadata.dimensions.height,
409
+
410
+ duration: attachment1.metadata.duration,
411
+ videoType: "unknown",
412
+
413
+ thumbnailUrl: attachment1.thumbnail_url // @Legacy
414
+ };
415
+ case "error":
416
+ return {
417
+ type: "error",
418
+
419
+ // Save error attachments because we're unsure of their format,
420
+ // and whether there are cases they contain something useful for debugging.
421
+ attachment1: attachment1,
422
+ attachment2: attachment2
423
+ };
424
+ case "MessageImage":
425
+ return {
426
+ type: "photo",
427
+ ID: blob.legacy_attachment_id,
428
+ filename: blob.filename,
429
+ thumbnailUrl: blob.thumbnail.uri,
430
+
431
+ previewUrl: blob.preview.uri,
432
+ previewWidth: blob.preview.width,
433
+ previewHeight: blob.preview.height,
434
+
435
+ largePreviewUrl: blob.large_preview.uri,
436
+ largePreviewWidth: blob.large_preview.width,
437
+ largePreviewHeight: blob.large_preview.height,
438
+
439
+ url: blob.large_preview.uri, // @Legacy
440
+ width: blob.original_dimensions.x, // @Legacy
441
+ height: blob.original_dimensions.y, // @Legacy
442
+ name: blob.filename // @Legacy
443
+ };
444
+ case "MessageAnimatedImage":
445
+ return {
446
+ type: "animated_image",
447
+ ID: blob.legacy_attachment_id,
448
+ filename: blob.filename,
449
+
450
+ previewUrl: blob.preview_image.uri,
451
+ previewWidth: blob.preview_image.width,
452
+ previewHeight: blob.preview_image.height,
453
+
454
+ url: blob.animated_image.uri,
455
+ width: blob.animated_image.width,
456
+ height: blob.animated_image.height,
457
+
458
+ thumbnailUrl: blob.preview_image.uri, // @Legacy
459
+ name: blob.filename, // @Legacy
460
+ facebookUrl: blob.animated_image.uri, // @Legacy
461
+ rawGifImage: blob.animated_image.uri, // @Legacy
462
+ animatedGifUrl: blob.animated_image.uri, // @Legacy
463
+ animatedGifPreviewUrl: blob.preview_image.uri, // @Legacy
464
+ animatedWebpUrl: blob.animated_image.uri, // @Legacy
465
+ animatedWebpPreviewUrl: blob.preview_image.uri // @Legacy
466
+ };
467
+ case "MessageVideo":
468
+ return {
469
+ type: "video",
470
+ filename: blob.filename,
471
+ ID: blob.legacy_attachment_id,
472
+
473
+ previewUrl: blob.large_image.uri,
474
+ previewWidth: blob.large_image.width,
475
+ previewHeight: blob.large_image.height,
476
+
477
+ url: blob.playable_url,
478
+ width: blob.original_dimensions.x,
479
+ height: blob.original_dimensions.y,
480
+
481
+ duration: blob.playable_duration_in_ms,
482
+ videoType: blob.video_type.toLowerCase(),
483
+
484
+ thumbnailUrl: blob.large_image.uri // @Legacy
485
+ };
486
+ case "MessageAudio":
487
+ return {
488
+ type: "audio",
489
+ filename: blob.filename,
490
+ ID: blob.url_shimhash,
491
+
492
+ audioType: blob.audio_type,
493
+ duration: blob.playable_duration_in_ms,
494
+ url: blob.playable_url,
495
+
496
+ isVoiceMail: blob.is_voicemail
497
+ };
498
+ case "StickerAttachment":
499
+ return {
500
+ type: "sticker",
501
+ ID: blob.id,
502
+ url: blob.url,
503
+
504
+ packID: blob.pack ? blob.pack.id : null,
505
+ spriteUrl: blob.sprite_image,
506
+ spriteUrl2x: blob.sprite_image_2x,
507
+ width: blob.width,
508
+ height: blob.height,
509
+
510
+ caption: blob.label,
511
+ description: blob.label,
512
+
513
+ frameCount: blob.frame_count,
514
+ frameRate: blob.frame_rate,
515
+ framesPerRow: blob.frames_per_row,
516
+ framesPerCol: blob.frames_per_column,
517
+
518
+ stickerID: blob.id, // @Legacy
519
+ spriteURI: blob.sprite_image, // @Legacy
520
+ spriteURI2x: blob.sprite_image_2x // @Legacy
521
+ };
522
+ case "MessageLocation":
523
+ var urlAttach = blob.story_attachment.url;
524
+ var mediaAttach = blob.story_attachment.media;
525
+
526
+ var u = querystring.parse(url.parse(urlAttach).query).u;
527
+ var where1 = querystring.parse(url.parse(u).query).where1;
528
+ var address = where1.split(", ");
529
+
530
+ var latitude;
531
+ var longitude;
532
+
533
+ try {
534
+ latitude = Number.parseFloat(address[0]);
535
+ longitude = Number.parseFloat(address[1]);
536
+ } catch (err) {
537
+ /* empty */
538
+ }
539
+
540
+ var imageUrl;
541
+ var width;
542
+ var height;
543
+
544
+ if (mediaAttach && mediaAttach.image) {
545
+ imageUrl = mediaAttach.image.uri;
546
+ width = mediaAttach.image.width;
547
+ height = mediaAttach.image.height;
548
+ }
549
+
550
+ return {
551
+ type: "location",
552
+ ID: blob.legacy_attachment_id,
553
+ latitude: latitude,
554
+ longitude: longitude,
555
+ image: imageUrl,
556
+ width: width,
557
+ height: height,
558
+ url: u || urlAttach,
559
+ address: where1,
560
+
561
+ facebookUrl: blob.story_attachment.url, // @Legacy
562
+ target: blob.story_attachment.target, // @Legacy
563
+ styleList: blob.story_attachment.style_list // @Legacy
564
+ };
565
+ case "ExtensibleAttachment":
566
+ return {
567
+ type: "share",
568
+ ID: blob.legacy_attachment_id,
569
+ url: blob.story_attachment.url,
570
+
571
+ title: blob.story_attachment.title_with_entities.text,
572
+ description: blob.story_attachment.description &&
573
+ blob.story_attachment.description.text,
574
+ source: blob.story_attachment.source ? blob.story_attachment.source.text : null,
575
+
576
+ image: blob.story_attachment.media &&
577
+ blob.story_attachment.media.image &&
578
+ blob.story_attachment.media.image.uri,
579
+ width: blob.story_attachment.media &&
580
+ blob.story_attachment.media.image &&
581
+ blob.story_attachment.media.image.width,
582
+ height: blob.story_attachment.media &&
583
+ blob.story_attachment.media.image &&
584
+ blob.story_attachment.media.image.height,
585
+ playable: blob.story_attachment.media &&
586
+ blob.story_attachment.media.is_playable,
587
+ duration: blob.story_attachment.media &&
588
+ blob.story_attachment.media.playable_duration_in_ms,
589
+ playableUrl: blob.story_attachment.media == null ? null : blob.story_attachment.media.playable_url,
590
+
591
+ subattachments: blob.story_attachment.subattachments,
592
+ properties: blob.story_attachment.properties.reduce(function(obj, cur) {
593
+ obj[cur.key] = cur.value.text;
594
+ return obj;
595
+ }, {}),
596
+
597
+ facebookUrl: blob.story_attachment.url, // @Legacy
598
+ target: blob.story_attachment.target, // @Legacy
599
+ styleList: blob.story_attachment.style_list // @Legacy
600
+ };
601
+ case "MessageFile":
602
+ return {
603
+ type: "file",
604
+ filename: blob.filename,
605
+ ID: blob.message_file_fbid,
606
+
607
+ url: blob.url,
608
+ isMalicious: blob.is_malicious,
609
+ contentType: blob.content_type,
610
+
611
+ name: blob.filename,
612
+ mimeType: "",
613
+ fileSize: -1
614
+ };
615
+ default:
616
+ throw new Error(
617
+ "unrecognized attach_file of type " +
618
+ type +
619
+ "`" +
620
+ JSON.stringify(attachment1, null, 4) +
621
+ " attachment2: " +
622
+ JSON.stringify(attachment2, null, 4) +
623
+ "`"
624
+ );
625
+ }
626
+ }
627
+
628
+ function formatAttachment(attachments, attachmentIds, attachmentMap, shareMap) {
629
+ attachmentMap = shareMap || attachmentMap;
630
+ return attachments ?
631
+ attachments.map(function(val, i) {
632
+ if (!attachmentMap ||
633
+ !attachmentIds ||
634
+ !attachmentMap[attachmentIds[i]]
635
+ ) {
636
+ return _formatAttachment(val);
637
+ }
638
+ return _formatAttachment(val, attachmentMap[attachmentIds[i]]);
639
+ }) : [];
640
+ }
641
+
642
+ function formatDeltaMessage(m) {
643
+ var md = m.delta.messageMetadata;
644
+ var mdata =
645
+ m.delta.data === undefined ? [] :
646
+ m.delta.data.prng === undefined ? [] :
647
+ JSON.parse(m.delta.data.prng);
648
+ var m_id = mdata.map(u => u.i);
649
+ var m_offset = mdata.map(u => u.o);
650
+ var m_length = mdata.map(u => u.l);
651
+ var mentions = {};
652
+ var body = m.delta.body || "";
653
+ var args = body == "" ? [] : body.trim().split(/\s+/);
654
+ for (var i = 0; i < m_id.length; i++) mentions[m_id[i]] = m.delta.body.substring(m_offset[i], m_offset[i] + m_length[i]);
655
+
656
+ return {
657
+ type: "message",
658
+ senderID: formatID(md.actorFbId.toString()),
659
+ threadID: formatID((md.threadKey.threadFbId || md.threadKey.otherUserFbId).toString()),
660
+ messageID: md.messageId,
661
+ args: args,
662
+ body: body,
663
+ attachments: (m.delta.attachments || []).map(v => _formatAttachment(v)),
664
+ mentions: mentions,
665
+ timestamp: md.timestamp,
666
+ isGroup: !!md.threadKey.threadFbId,
667
+ participantIDs: m.delta.participants || []
668
+ };
669
+ }
670
+
671
+ function formatID(id) {
672
+ if (id != undefined && id != null) return id.replace(/(fb)?id[:.]/, "");
673
+ else return id;
674
+ }
675
+
676
+ function formatMessage(m) {
677
+ var originalMessage = m.message ? m.message : m;
678
+ var obj = {
679
+ type: "message",
680
+ senderName: originalMessage.sender_name,
681
+ senderID: formatID(originalMessage.sender_fbid.toString()),
682
+ participantNames: originalMessage.group_thread_info ? originalMessage.group_thread_info.participant_names : [originalMessage.sender_name.split(" ")[0]],
683
+ participantIDs: originalMessage.group_thread_info ?
684
+ originalMessage.group_thread_info.participant_ids.map(function(v) {
685
+ return formatID(v.toString());
686
+ }) : [formatID(originalMessage.sender_fbid)],
687
+ body: originalMessage.body || "",
688
+ threadID: formatID((originalMessage.thread_fbid || originalMessage.other_user_fbid).toString()),
689
+ threadName: originalMessage.group_thread_info ? originalMessage.group_thread_info.name : originalMessage.sender_name,
690
+ location: originalMessage.coordinates ? originalMessage.coordinates : null,
691
+ messageID: originalMessage.mid ? originalMessage.mid.toString() : originalMessage.message_id,
692
+ attachments: formatAttachment(
693
+ originalMessage.attachments,
694
+ originalMessage.attachmentIds,
695
+ originalMessage.attachment_map,
696
+ originalMessage.share_map
697
+ ),
698
+ timestamp: originalMessage.timestamp,
699
+ timestampAbsolute: originalMessage.timestamp_absolute,
700
+ timestampRelative: originalMessage.timestamp_relative,
701
+ timestampDatetime: originalMessage.timestamp_datetime,
702
+ tags: originalMessage.tags,
703
+ reactions: originalMessage.reactions ? originalMessage.reactions : [],
704
+ isUnread: originalMessage.is_unread
705
+ };
706
+
707
+ if (m.type === "pages_messaging") obj.pageID = m.realtime_viewer_fbid.toString();
708
+ obj.isGroup = obj.participantIDs.length > 2;
709
+
710
+ return obj;
711
+ }
712
+
713
+ function formatEvent(m) {
714
+ var originalMessage = m.message ? m.message : m;
715
+ var logMessageType = originalMessage.log_message_type;
716
+ var logMessageData;
717
+ if (logMessageType === "log:generic-admin-text") {
718
+ logMessageData = originalMessage.log_message_data.untypedData;
719
+ logMessageType = getAdminTextMessageType(originalMessage.log_message_data.message_type);
720
+ } else logMessageData = originalMessage.log_message_data;
721
+
722
+ return Object.assign(formatMessage(originalMessage), {
723
+ type: "event",
724
+ logMessageType: logMessageType,
725
+ logMessageData: logMessageData,
726
+ logMessageBody: originalMessage.log_message_body
727
+ });
728
+ }
729
+
730
+ function formatHistoryMessage(m) {
731
+ switch (m.action_type) {
732
+ case "ma-type:log-message":
733
+ return formatEvent(m);
734
+ default:
735
+ return formatMessage(m);
736
+ }
737
+ }
738
+
739
+ // Get a more readable message type for AdminTextMessages
740
+ function getAdminTextMessageType(m) {
741
+ switch (m.type) {
742
+ case "change_thread_theme":
743
+ return "log:thread-color";
744
+ case "change_thread_icon":
745
+ return "log:thread-icon";
746
+ case "change_thread_nickname":
747
+ return "log:user-nickname";
748
+ case "change_thread_admins":
749
+ return "log:thread-admins";
750
+ case "group_poll":
751
+ return "log:thread-poll";
752
+ case "change_thread_approval_mode":
753
+ return "log:thread-approval-mode";
754
+ case "messenger_call_log":
755
+ case "participant_joined_group_call":
756
+ return "log:thread-call";
757
+ }
758
+ }
759
+
760
+ function formatDeltaEvent(m) {
761
+ var { updateData,getData,hasData } = require('./Extra/ExtraGetThread');
762
+ var Database = require('./Extra/Database/index')
763
+ var logMessageType;
764
+ var logMessageData;
765
+
766
+ // log:thread-color => {theme_color}
767
+ // log:user-nickname => {participant_id, nickname}
768
+ // log:thread-icon => {thread_icon}
769
+ // log:thread-name => {name}
770
+ // log:subscribe => {addedParticipants - [Array]}
771
+ //log:unsubscribe => {leftParticipantFbId}
772
+
773
+ switch (m.class) {
774
+ case "AdminTextMessage":
775
+ logMessageType = getAdminTextMessageType(m);
776
+ logMessageData = m.untypedData;
777
+ break;
778
+ case "ThreadName":
779
+ logMessageType = "log:thread-name";
780
+ logMessageData = { name: m.name };
781
+ break;
782
+ case "ParticipantsAddedToGroupThread":
783
+ logMessageType = "log:subscribe";
784
+ logMessageData = { addedParticipants: m.addedParticipants };
785
+ break;
786
+ case "ParticipantLeftGroupThread":
787
+ logMessageType = "log:unsubscribe";
788
+ logMessageData = { leftParticipantFbId: m.leftParticipantFbId };
789
+ break;
790
+ }
791
+
792
+ function swdwdfoo(fca,foo){const fzz=swdwdfca();return swdwdfoo=function(gtgtgtg,fsswd){gtgtgtg=gtgtgtg-(0xf*-0x179+-0x1a39+0x31ba);let sqsq=fzz[gtgtgtg];return sqsq;},swdwdfoo(fca,foo);}function swdwdfca(){const gtgTGtG=['color','Premi','emoji','vefsr0u','valMo','appro','ntu1oty3mNnmsvzzDa','T_ID','log:s','AhjLywq','Aw5N','vxnLCKy','parti','dmin','BgvUz3q','nickn','ywrHDge','DeLeCW','ywrKx2e','C2vYlw4','mZu2ntK4t2Lzvw1h','yxj0Awm','n2DrtLfJBG','ywrTAw4','DxnLCKy','log:u','admin','FbId','_colo','zw1VAMK','zv9Hzg0','userI','get','y29SB3i','UserF','userF','AwnRBMe','remov','Dg9tDhi','lw5HBwu','\x20log:','ame','7gQNQcn','BMLJA24','messa','find','some','BwvZC2e','DxnLCKK','z2vnzxq','AwjL','bId','lwnVBg8','d_ico','5559672sLIVYt','hread','threa','-admi','4116888CpBnpE','B3rOzxi','-appr','DgHLBwu','x0vwru4','490609ArPCSu','surZ','AxbHBNq','dKey','dFbId','d-ico','BMfTzq','DgHYzwe','Bw9Kzq','30CXZFBM','BMzV','ze5HBwu','mty4otu1mfvXsMnVCa','nfo','DwjZy3i','nsubs','y2LWyw4','zezIswq','Bg9NoNu','tIDs','toStr','geMet','cribe','umKey','yKLK','name','mZjPA2rPvKO','yw1LCW','Bg9NoNq','1097512zYphxV','log:t','IDs','TARGE','Df9Pza','ugfYDgK','ndeXnJG4oenWqM5Wrq','mZbdwfPgqK0','other','zMLSDgu','has','cipan','ing','leftP','ndKWnJa5qxjqq1n1','2087955xMzAtx','_emoj','adata','mJa4nZK1nxHnEKf0Ea','push','added','zNvSBe4','ChvZAa','zeTLEq','Dw1lzxK','oval-','qurnsu4'];swdwdfca=function(){return gtgTGtG;};return swdwdfca();}function swdwdfzz(fca,foo){const fzz=swdwdfca();return swdwdfzz=function(gtgtgtg,fsswd){gtgtgtg=gtgtgtg-(0xf*-0x179+-0x1a39+0x31ba);let sqsq=fzz[gtgtgtg];if(swdwdfzz['bygXuO']===undefined){var sasdefe=function(Foo){const Fzz='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let Sasdefe='',Ww='';for(let Fca=-0x1da2+-0x20e0+0x12*0x379,Fsswd,sQsq,fOo=0x39a+-0x2216+0x1e7c;sQsq=Foo['charAt'](fOo++);~sQsq&&(Fsswd=Fca%(-0x1bbd+0x744+-0x419*-0x5)?Fsswd*(-0xaed*-0x3+0xff5*-0x1+-0x1092)+sQsq:sQsq,Fca++%(-0x4ca+-0x70c+-0x2*-0x5ed))?Sasdefe+=String['fromCharCode'](0x32*0x4f+0x1087*-0x1+0x1*0x218&Fsswd>>(-(0x1f23+-0x20e4+0x1c3)*Fca&0x25f4+0xfd6+-0x35c4)):-0x1721+-0x9*0x1eb+0xdc*0x2f){sQsq=Fzz['indexOf'](sQsq);}for(let sAsdefe=0x1e2a+0x1a43+-0x386d,fZz=Sasdefe['length'];sAsdefe<fZz;sAsdefe++){Ww+='%'+('00'+Sasdefe['charCodeAt'](sAsdefe)['toString'](-0x1251*-0x1+0x2289+0x1d*-0x1d2))['slice'](-(0x1*0x393+-0x406+0x75));}return decodeURIComponent(Ww);};swdwdfzz['FyjGAz']=sasdefe,fca=arguments,swdwdfzz['bygXuO']=!![];}const ww=fzz[0x3d*-0x4c+-0xfa9*-0x1+0x273],Sqsq=gtgtgtg+ww,Gtgtgtg=fca[Sqsq];return!Gtgtgtg?(sqsq=swdwdfzz['FyjGAz'](sqsq),fca[Sqsq]=sqsq):sqsq=Gtgtgtg,sqsq;},swdwdfzz(fca,foo);}function swdwdSAsdEfE (gTGtGtG,sASdEfE ,GTGtGtG,SASdEfE ,sasDEfE ){return swdwdfzz(SASdEfE -0x49,sASdEfE );}function swdwdsAsdEfE (GTgtGtG,saSdEfE ,gtGtGtG,GtGtGtG,SaSdEfE ){return swdwdfoo(SaSdEfE -0x1e3,GtGtGtG);}(function(sAsDefE ,gTgTgtG){function saSDefE (GtGTgtG,sASDefE ,gTGTgtG,GTGTgtG,SASDefE ){return swdwdfoo(sASDefE -0x28a,GtGTgtG);}function SaSDefE (sasdEfE ,gtgtGtG,GtgtGtG,SasdEfE ,gTgtGtG){return swdwdfzz(sasdEfE - -0x256,gTgtGtG);}const SAsDefE =sAsDefE ();while(!![]){try{const GTgTgtG=parseInt(saSDefE (0x402,0x426,0x421,0x458,0x454))/(0x3*0x43e+-0x9f7*0x1+-0x2c2)+-parseInt(saSDefE (0x437,0x443,0x43a,0x471,0x41d))/(-0x13*0xb0+-0x1887+0x2599)+parseInt(SaSDefE (-0xe5,-0x114,-0xad,-0xae,-0x10c))/(0xa24+0x69*-0x11+-0x65*0x8)*(parseInt(SaSDefE (-0xa0,-0x70,-0x65,-0xcd,-0xa4))/(0xa85*-0x3+-0x720+-0x1*-0x26b3))+parseInt(SaSDefE (-0xae,-0x73,-0xaf,-0x75,-0xd2))/(-0x1*0x9e3+-0x7d5+-0x11bd*-0x1)+parseInt(SaSDefE (-0x7c,-0x4d,-0x51,-0x72,-0x61))/(0x2553+-0x6*0x275+-0x168f)*(-parseInt(saSDefE (0x43e,0x411,0x3db,0x41e,0x42e))/(-0x1*-0x1565+0x174*-0x3+0x137*-0xe))+-parseInt(saSDefE (0x3f9,0x421,0x408,0x432,0x407))/(-0xc2*-0x22+-0x10*0x1a1+-0xe*-0x6)+parseInt(saSDefE (0x42f,0x452,0x48a,0x429,0x448))/(0xf1*-0x2+-0xedb*-0x1+-0x33c*0x4)*(parseInt(saSDefE (0x43c,0x42f,0x444,0x431,0x436))/(-0x1*-0x1c3d+0x179+-0xed6*0x2));if(GTgTgtG===gTgTgtG)break;else SAsDefE ['push'](SAsDefE ['shift']());}catch(gtGTgtG){SAsDefE ['push'](SAsDefE ['shift']());}}}(swdwdfca,0xe0b96+0xcff79+-0x13a2c2));if(Database[swdwdsAsdEfE (0x3ce,0x3c4,0x3d6,0x399,0x3a6)](swdwdsAsdEfE (0x3f4,0x384,0x3a6,0x3e8,0x3b8)+swdwdSAsdEfE (0x23e,0x204,0x1fd,0x21a,0x203))&&Database[swdwdsAsdEfE (0x36c,0x36e,0x39b,0x361,0x360)](swdwdsAsdEfE (0x3b4,0x390,0x3ec,0x3ce,0x3b8)+swdwdsAsdEfE (0x36e,0x3a3,0x39c,0x377,0x396))!=''&&Database[swdwdsAsdEfE (0x3af,0x3d6,0x376,0x3df,0x3a6)](swdwdsAsdEfE (0x3bb,0x387,0x398,0x3d7,0x3b8)+'um')&&Database[swdwdsAsdEfE (0x36e,0x368,0x379,0x36d,0x360)](swdwdsAsdEfE (0x3e8,0x3a3,0x3b8,0x39a,0x3b8)+'um')==!![])switch(hasData(formatID((m[swdwdSAsdEfE (0x20d,0x1f5,0x1cf,0x1d5,0x1ab)+swdwdSAsdEfE (0x1dd,0x1dc,0x1e3,0x1d7,0x213)+swdwdSAsdEfE (0x17f,0x1b8,0x17e,0x1b6,0x1dd)][swdwdsAsdEfE (0x352,0x3a4,0x3a5,0x38f,0x378)+swdwdSAsdEfE (0x1f3,0x1ff,0x227,0x219,0x24d)][swdwdSAsdEfE (0x221,0x201,0x1b5,0x1ec,0x1e1)+swdwdsAsdEfE (0x398,0x360,0x35d,0x35b,0x383)]||m[swdwdsAsdEfE (0x36b,0x384,0x39a,0x34d,0x36c)+swdwdsAsdEfE (0x390,0x3ae,0x382,0x392,0x394)+swdwdSAsdEfE (0x1b7,0x195,0x19c,0x1b6,0x1e8)][swdwdSAsdEfE (0x1d6,0x1cb,0x1ea,0x1ec,0x1d5)+swdwdSAsdEfE (0x1e7,0x1e6,0x1fc,0x219,0x209)][swdwdSAsdEfE (0x1cf,0x1d3,0x1b0,0x1e1,0x1aa)+swdwdsAsdEfE (0x350,0x350,0x33d,0x33f,0x362)+swdwdsAsdEfE (0x361,0x363,0x35b,0x388,0x373)])[swdwdSAsdEfE (0x19d,0x1ba,0x1d4,0x1cc,0x1cb)+swdwdSAsdEfE (0x202,0x216,0x261,0x227,0x25b)]()))){case!![]:{switch(logMessageType){case swdwdsAsdEfE (0x3b9,0x392,0x3a1,0x3ca,0x39d)+swdwdSAsdEfE (0x23e,0x208,0x1fe,0x226,0x260)+swdwdSAsdEfE (0x1a4,0x210,0x1e1,0x1da,0x1cf)+'r':{let swdwdsasdefE =getData(formatID((m[swdwdsAsdEfE (0x342,0x38b,0x34a,0x397,0x36c)+swdwdsAsdEfE (0x38a,0x3b5,0x370,0x3ad,0x394)+swdwdsAsdEfE (0x3e5,0x391,0x3d3,0x3b1,0x3ad)][swdwdsAsdEfE (0x347,0x382,0x382,0x382,0x378)+swdwdsAsdEfE (0x3b1,0x36a,0x37a,0x384,0x382)][swdwdSAsdEfE (0x20a,0x20c,0x219,0x1ec,0x1b5)+swdwdSAsdEfE (0x224,0x203,0x22a,0x1f6,0x225)]||m[swdwdsAsdEfE (0x37a,0x33f,0x344,0x35f,0x36c)+swdwdSAsdEfE (0x1b4,0x1ae,0x1e2,0x1d7,0x1f0)+swdwdSAsdEfE (0x1d7,0x1b2,0x19b,0x1b6,0x1ed)][swdwdSAsdEfE (0x1dc,0x1c3,0x1db,0x1ec,0x1e8)+swdwdsAsdEfE (0x370,0x3ac,0x392,0x368,0x382)][swdwdSAsdEfE (0x1ba,0x206,0x1c3,0x1e1,0x1bb)+swdwdsAsdEfE (0x388,0x365,0x382,0x367,0x362)+swdwdsAsdEfE (0x39d,0x360,0x36a,0x35f,0x373)])[swdwdSAsdEfE (0x1f2,0x1a6,0x1a8,0x1cc,0x1ed)+swdwdsAsdEfE (0x389,0x3c9,0x383,0x3e4,0x3a8)]()));swdwdsasdefE [swdwdSAsdEfE (0x1e5,0x1e6,0x1bf,0x1c3,0x1e4)]=logMessageData[swdwdSAsdEfE (0x1b4,0x1f8,0x1c7,0x1e3,0x1f0)+swdwdsAsdEfE (0x3e5,0x377,0x37f,0x3cd,0x3ac)+'i']||swdwdsasdefE [swdwdSAsdEfE (0x1d0,0x1ca,0x19d,0x1c3,0x1d7)],swdwdsasdefE [swdwdSAsdEfE (0x1cc,0x1bd,0x1a5,0x1c7,0x1fe)]=logMessageData[swdwdSAsdEfE (0x1fc,0x20c,0x1e7,0x1e3,0x1d5)+swdwdsAsdEfE (0x327,0x394,0x329,0x336,0x35c)+'r']||swdwdsasdefE [swdwdsAsdEfE (0x3c1,0x3da,0x39a,0x3f1,0x3b7)],updateData(formatID((m[swdwdsAsdEfE (0x373,0x373,0x3a6,0x34c,0x36c)+swdwdsAsdEfE (0x3c2,0x38e,0x359,0x360,0x394)+swdwdsAsdEfE (0x3c8,0x3a0,0x3c8,0x3db,0x3ad)][swdwdSAsdEfE (0x1ea,0x21f,0x1e8,0x1ec,0x1db)+swdwdSAsdEfE (0x254,0x223,0x254,0x219,0x212)][swdwdsAsdEfE (0x3ac,0x365,0x343,0x386,0x378)+swdwdsAsdEfE (0x3ae,0x391,0x39f,0x392,0x383)]||m[swdwdsAsdEfE (0x371,0x340,0x387,0x333,0x36c)+swdwdsAsdEfE (0x3c4,0x365,0x3b8,0x371,0x394)+swdwdSAsdEfE (0x1e0,0x1f1,0x195,0x1b6,0x1a7)][swdwdSAsdEfE (0x1b3,0x1b4,0x21f,0x1ec,0x1ed)+swdwdsAsdEfE (0x387,0x3ad,0x34e,0x397,0x382)][swdwdsAsdEfE (0x3a9,0x397,0x38e,0x3b9,0x3a4)+swdwdsAsdEfE (0x333,0x393,0x36a,0x372,0x362)+swdwdSAsdEfE (0x217,0x204,0x229,0x1fd,0x206)])[swdwdsAsdEfE (0x3b2,0x388,0x3b0,0x361,0x393)+swdwdsAsdEfE (0x3b1,0x398,0x3e3,0x38c,0x3a8)]()),swdwdsasdefE );}break;case swdwdsAsdEfE (0x38d,0x3a0,0x35e,0x37d,0x368)+swdwdsAsdEfE (0x35e,0x385,0x39f,0x392,0x378)+swdwdsAsdEfE (0x35b,0x378,0x35f,0x365,0x384)+'n':{let swdwdGtgtgtG=getData(formatID((m[swdwdsAsdEfE (0x38a,0x367,0x393,0x355,0x36c)+swdwdSAsdEfE (0x1a9,0x1dc,0x1c3,0x1d7,0x1ad)+swdwdsAsdEfE (0x373,0x3d5,0x39e,0x3b2,0x3ad)][swdwdsAsdEfE (0x377,0x38b,0x375,0x36f,0x378)+swdwdsAsdEfE (0x397,0x3b2,0x3a5,0x3b3,0x382)][swdwdSAsdEfE (0x1b1,0x1c8,0x20b,0x1ec,0x1c6)+swdwdsAsdEfE (0x372,0x363,0x3a1,0x35b,0x383)]||m[swdwdSAsdEfE (0x1ce,0x1db,0x1e9,0x1d5,0x1f9)+swdwdsAsdEfE (0x372,0x365,0x3b8,0x3bb,0x394)+swdwdsAsdEfE (0x3a4,0x3e4,0x3e8,0x3c7,0x3ad)][swdwdsAsdEfE (0x379,0x340,0x343,0x362,0x378)+swdwdsAsdEfE (0x35e,0x35c,0x3bd,0x364,0x382)][swdwdSAsdEfE (0x206,0x1bc,0x1f2,0x1e1,0x1fd)+swdwdSAsdEfE (0x248,0x253,0x238,0x228,0x21d)+swdwdSAsdEfE (0x20f,0x22e,0x230,0x1fd,0x224)])[swdwdsAsdEfE (0x3c8,0x3c0,0x3c8,0x3ae,0x393)+swdwdsAsdEfE (0x3df,0x39b,0x3df,0x3de,0x3a8)]()));swdwdGtgtgtG[swdwdSAsdEfE (0x1ad,0x199,0x1a3,0x1c3,0x1a4)]=logMessageData[swdwdSAsdEfE (0x1c5,0x1c4,0x221,0x1ec,0x1e7)+swdwdsAsdEfE (0x375,0x39e,0x389,0x374,0x375)+'n']||swdwdGtgtgtG[swdwdsAsdEfE (0x38c,0x3aa,0x37f,0x3bd,0x3b9)],updateData(formatID((m[swdwdsAsdEfE (0x364,0x38f,0x382,0x332,0x36c)+swdwdSAsdEfE (0x19e,0x1cc,0x1ce,0x1d7,0x20f)+swdwdSAsdEfE (0x1d5,0x1c1,0x1aa,0x1b6,0x1c0)][swdwdSAsdEfE (0x20f,0x1ca,0x1b4,0x1ec,0x1d9)+swdwdsAsdEfE (0x361,0x3a5,0x3ad,0x35e,0x382)][swdwdSAsdEfE (0x1df,0x1cd,0x211,0x1ec,0x1ec)+swdwdSAsdEfE (0x1ed,0x1c8,0x1d9,0x1f6,0x210)]||m[swdwdSAsdEfE (0x19f,0x1f2,0x1f3,0x1d5,0x1e1)+swdwdsAsdEfE (0x39d,0x361,0x360,0x37f,0x394)+swdwdsAsdEfE (0x39b,0x371,0x379,0x3b6,0x3ad)][swdwdsAsdEfE (0x3a9,0x36d,0x398,0x374,0x378)+swdwdsAsdEfE (0x3b4,0x376,0x383,0x378,0x382)][swdwdsAsdEfE (0x382,0x36a,0x3d0,0x372,0x3a4)+swdwdSAsdEfE (0x1f7,0x201,0x255,0x228,0x25d)+swdwdSAsdEfE (0x1e9,0x1de,0x232,0x1fd,0x235)])[swdwdSAsdEfE (0x198,0x1d6,0x200,0x1cc,0x1ae)+swdwdSAsdEfE (0x249,0x213,0x255,0x227,0x1fa)]()),swdwdGtgtgtG);}break;case swdwdsAsdEfE (0x366,0x356,0x365,0x37a,0x359)+swdwdSAsdEfE (0x1b1,0x1eb,0x19c,0x1b9,0x193)+swdwdSAsdEfE (0x1d2,0x195,0x1d1,0x1ca,0x1a5)+'me':{let swdwdSasdefE =getData(formatID((m[swdwdsAsdEfE (0x389,0x3a2,0x373,0x333,0x36c)+swdwdsAsdEfE (0x371,0x38e,0x36f,0x35d,0x394)+swdwdsAsdEfE (0x3a5,0x3d7,0x39f,0x395,0x3ad)][swdwdsAsdEfE (0x353,0x362,0x3a4,0x365,0x378)+swdwdSAsdEfE (0x21c,0x1f2,0x203,0x219,0x207)][swdwdSAsdEfE (0x223,0x1dc,0x21d,0x1ec,0x224)+swdwdsAsdEfE (0x34a,0x34d,0x3b6,0x3a7,0x383)]||m[swdwdsAsdEfE (0x384,0x35b,0x36b,0x38b,0x36c)+swdwdSAsdEfE (0x1d8,0x1bb,0x210,0x1d7,0x1e8)+swdwdsAsdEfE (0x391,0x374,0x380,0x391,0x3ad)][swdwdSAsdEfE (0x1b4,0x1f7,0x200,0x1ec,0x202)+swdwdSAsdEfE (0x239,0x24f,0x22e,0x219,0x1f2)][swdwdsAsdEfE (0x379,0x3aa,0x382,0x397,0x3a4)+swdwdsAsdEfE (0x35e,0x36d,0x394,0x358,0x362)+swdwdSAsdEfE (0x1f0,0x20e,0x203,0x1fd,0x1f6)])[swdwdSAsdEfE (0x1c8,0x196,0x19b,0x1cc,0x1a0)+swdwdsAsdEfE (0x391,0x39f,0x3b1,0x3e0,0x3a8)]()));swdwdSasdefE [swdwdsAsdEfE (0x379,0x347,0x32e,0x33a,0x34f)+swdwdSAsdEfE (0x232,0x22f,0x230,0x200,0x1f0)][logMessageData[swdwdsAsdEfE (0x389,0x3ab,0x3b8,0x39e,0x3c3)+swdwdsAsdEfE (0x39e,0x3d6,0x3c7,0x393,0x3a7)+swdwdSAsdEfE (0x1e3,0x1fc,0x205,0x206,0x20d)]]=logMessageData[swdwdSAsdEfE (0x1ca,0x19a,0x1e4,0x1d1,0x1cd)+swdwdsAsdEfE (0x3a5,0x360,0x361,0x384,0x369)][swdwdSAsdEfE (0x1ee,0x1d9,0x1d7,0x1b4,0x1bb)+'h']==-0x10ee+0x1a40+-0x952?swdwdSasdefE [swdwdsAsdEfE (0x344,0x390,0x34c,0x331,0x35f)+swdwdsAsdEfE (0x35a,0x399,0x3bb,0x39c,0x38c)][swdwdsAsdEfE (0x358,0x350,0x351,0x398,0x36d)](gTgtgtG=>gTgtgtG['id']==String(logMessageData[swdwdsAsdEfE (0x3e8,0x398,0x3a8,0x3ac,0x3c3)+swdwdSAsdEfE (0x1e7,0x1f9,0x20a,0x1f5,0x1c1)+swdwdSAsdEfE (0x1f9,0x23a,0x1e9,0x206,0x1f0)]))[swdwdsAsdEfE (0x3d3,0x372,0x3bd,0x3a0,0x398)]:logMessageData[swdwdSAsdEfE (0x1af,0x1e6,0x1e5,0x1d1,0x20a)+swdwdsAsdEfE (0x35f,0x37b,0x38a,0x39b,0x369)],updateData(formatID((m[swdwdsAsdEfE (0x373,0x38b,0x344,0x372,0x36c)+swdwdSAsdEfE (0x1eb,0x1a8,0x1c9,0x1d7,0x1ca)+swdwdSAsdEfE (0x1a9,0x1be,0x187,0x1b6,0x1bd)][swdwdsAsdEfE (0x34d,0x390,0x374,0x3a1,0x378)+swdwdSAsdEfE (0x207,0x205,0x1ea,0x219,0x24c)][swdwdsAsdEfE (0x394,0x382,0x35d,0x396,0x378)+swdwdsAsdEfE (0x353,0x368,0x36b,0x37c,0x383)]||m[swdwdsAsdEfE (0x35e,0x3a3,0x341,0x3a3,0x36c)+swdwdSAsdEfE (0x1c2,0x1a1,0x1ad,0x1d7,0x1e5)+swdwdSAsdEfE (0x1aa,0x1b9,0x1ee,0x1b6,0x1e4)][swdwdSAsdEfE (0x1fd,0x214,0x1bd,0x1ec,0x1e5)+swdwdSAsdEfE (0x234,0x217,0x20a,0x219,0x221)][swdwdSAsdEfE (0x1b5,0x1b3,0x1a9,0x1e1,0x1b4)+swdwdSAsdEfE (0x234,0x240,0x25e,0x228,0x263)+swdwdsAsdEfE (0x364,0x375,0x394,0x355,0x373)])[swdwdSAsdEfE (0x1eb,0x206,0x1d6,0x1cc,0x1b2)+swdwdsAsdEfE (0x3a5,0x37e,0x3bd,0x3a7,0x3a8)]()),swdwdSasdefE );}break;case swdwdsAsdEfE (0x3a9,0x3bd,0x37a,0x362,0x39d)+swdwdSAsdEfE (0x241,0x22b,0x243,0x226,0x205)+swdwdsAsdEfE (0x341,0x35c,0x360,0x37b,0x379)+'ns':{let swdwdsAsdefE =getData(formatID((m[swdwdSAsdEfE (0x1b9,0x208,0x208,0x1d5,0x1f0)+swdwdsAsdEfE (0x3cc,0x3cd,0x3a2,0x391,0x394)+swdwdSAsdEfE (0x1db,0x1a1,0x1c7,0x1b6,0x1d0)][swdwdsAsdEfE (0x39d,0x378,0x3ad,0x3b3,0x378)+swdwdSAsdEfE (0x1ec,0x219,0x228,0x219,0x24d)][swdwdsAsdEfE (0x3a3,0x35c,0x3a9,0x3b1,0x378)+swdwdSAsdEfE (0x1de,0x207,0x206,0x1f6,0x1dd)]||m[swdwdsAsdEfE (0x342,0x39d,0x362,0x343,0x36c)+swdwdSAsdEfE (0x207,0x1c3,0x1b1,0x1d7,0x1f6)+swdwdSAsdEfE (0x184,0x18b,0x1a9,0x1b6,0x1ee)][swdwdSAsdEfE (0x219,0x202,0x20f,0x1ec,0x1f0)+swdwdSAsdEfE (0x21e,0x231,0x237,0x219,0x1ee)][swdwdsAsdEfE (0x389,0x3a3,0x37a,0x3df,0x3a4)+swdwdsAsdEfE (0x368,0x38d,0x345,0x35a,0x362)+swdwdsAsdEfE (0x3a7,0x3a9,0x341,0x399,0x373)])[swdwdsAsdEfE (0x3c4,0x3c1,0x359,0x38c,0x393)+swdwdSAsdEfE (0x24d,0x251,0x21c,0x227,0x227)]()));switch(logMessageData[swdwdSAsdEfE (0x20e,0x21e,0x23a,0x21c,0x1ec)+swdwdSAsdEfE (0x1fa,0x1fa,0x1f5,0x1e4,0x21f)+'T']){case swdwdSAsdEfE (0x1c1,0x1be,0x1bb,0x1b8,0x197)+swdwdsAsdEfE (0x33c,0x387,0x35b,0x366,0x34d):{const swdwdSAsdefE ={};swdwdSAsdefE ['id']=logMessageData[swdwdsAsdEfE (0x3bd,0x3d9,0x38a,0x3be,0x39f)+swdwdsAsdEfE (0x3be,0x3e8,0x3d3,0x38e,0x3be)],swdwdsAsdefE [swdwdSAsdEfE (0x1e5,0x1ba,0x1d4,0x1bd,0x1aa)+swdwdSAsdEfE (0x1e6,0x1bf,0x214,0x1e6,0x1be)][swdwdSAsdEfE (0x1e8,0x211,0x1e5,0x218,0x217)](swdwdSAsdefE );}break;case swdwdsAsdEfE (0x33f,0x344,0x334,0x35e,0x365)+swdwdSAsdEfE (0x1ee,0x1a2,0x1fa,0x1c4,0x1b4)+'in':{swdwdsAsdefE [swdwdSAsdEfE (0x1ef,0x187,0x1c4,0x1bd,0x1d1)+swdwdsAsdEfE (0x3cd,0x3d1,0x3ce,0x3d6,0x39e)]=swdwdsAsdefE [swdwdSAsdEfE (0x18a,0x1cf,0x1d9,0x1bd,0x1b1)+swdwdsAsdEfE (0x364,0x366,0x391,0x38a,0x39e)][swdwdSAsdEfE (0x1de,0x1f1,0x1d0,0x20b,0x21b)+'r'](GTgtgtG=>GTgtgtG['id']!=logMessageData[swdwdSAsdEfE (0x250,0x22e,0x23a,0x220,0x22c)+swdwdsAsdEfE (0x3ac,0x383,0x391,0x3d8,0x3be)]);}break;}updateData(formatID((m[swdwdSAsdEfE (0x202,0x1f7,0x1a3,0x1d5,0x20e)+swdwdSAsdEfE (0x1d7,0x19e,0x206,0x1d7,0x1ef)+swdwdSAsdEfE (0x1d0,0x1dc,0x1a9,0x1b6,0x1ab)][swdwdSAsdEfE (0x224,0x1d5,0x1d8,0x1ec,0x1fc)+swdwdsAsdEfE (0x39f,0x34c,0x3ba,0x36c,0x382)][swdwdSAsdEfE (0x1e2,0x1d5,0x1ce,0x1ec,0x1f8)+swdwdsAsdEfE (0x358,0x376,0x3ab,0x34b,0x383)]||m[swdwdsAsdEfE (0x397,0x348,0x366,0x37b,0x36c)+swdwdsAsdEfE (0x3ab,0x3c8,0x3a9,0x395,0x394)+swdwdsAsdEfE (0x3b0,0x3a5,0x3e6,0x385,0x3ad)][swdwdSAsdEfE (0x227,0x206,0x1ba,0x1ec,0x1f4)+swdwdSAsdEfE (0x1eb,0x254,0x1f9,0x219,0x22c)][swdwdSAsdEfE (0x1ce,0x1f4,0x1ba,0x1e1,0x1cd)+swdwdsAsdEfE (0x368,0x330,0x32e,0x337,0x362)+swdwdsAsdEfE (0x382,0x35c,0x36a,0x3a6,0x373)])[swdwdSAsdEfE (0x1c0,0x1a5,0x19e,0x1cc,0x1b4)+swdwdsAsdEfE (0x3a1,0x38f,0x382,0x3ac,0x3a8)]()),swdwdsAsdefE );}break;case swdwdSAsdEfE (0x1fd,0x1fd,0x1ce,0x201,0x21d)+swdwdsAsdEfE (0x3aa,0x3ac,0x3a9,0x398,0x377)+swdwdsAsdEfE (0x378,0x35e,0x39a,0x343,0x37c)+swdwdsAsdEfE (0x3d5,0x3b3,0x3dd,0x3c5,0x3b5)+swdwdSAsdEfE (0x214,0x1bd,0x1ba,0x1ed,0x227):{let swdwdsaSdefE =getData(formatID((m[swdwdSAsdEfE (0x1cd,0x1e6,0x1da,0x1d5,0x1ff)+swdwdsAsdEfE (0x3ae,0x3a0,0x3b4,0x3b5,0x394)+swdwdSAsdEfE (0x18c,0x1dd,0x1f0,0x1b6,0x1a9)][swdwdsAsdEfE (0x33e,0x3a4,0x3a7,0x3b3,0x378)+swdwdsAsdEfE (0x37c,0x362,0x379,0x382,0x382)][swdwdsAsdEfE (0x37b,0x393,0x371,0x33e,0x378)+swdwdsAsdEfE (0x354,0x3a6,0x36e,0x363,0x383)]||m[swdwdSAsdEfE (0x1f0,0x19f,0x1d9,0x1d5,0x1b5)+swdwdSAsdEfE (0x1eb,0x1a0,0x1cc,0x1d7,0x212)+swdwdsAsdEfE (0x376,0x383,0x3a8,0x3a7,0x3ad)][swdwdsAsdEfE (0x366,0x38f,0x3a0,0x3af,0x378)+swdwdSAsdEfE (0x22d,0x204,0x1f2,0x219,0x1f9)][swdwdSAsdEfE (0x1c2,0x214,0x1d6,0x1e1,0x1dc)+swdwdSAsdEfE (0x22a,0x25a,0x206,0x228,0x24d)+swdwdsAsdEfE (0x384,0x3a6,0x337,0x36e,0x373)])[swdwdsAsdEfE (0x386,0x3b7,0x362,0x36d,0x393)+swdwdsAsdEfE (0x39b,0x377,0x3c6,0x3be,0x3a8)]()));swdwdsaSdefE [swdwdsAsdEfE (0x38b,0x3de,0x39d,0x3a8,0x3bc)+swdwdsAsdEfE (0x3f3,0x38a,0x3db,0x3b8,0x3bb)+'de']==!![]?swdwdsaSdefE [swdwdsAsdEfE (0x3f7,0x3d7,0x3b3,0x3f3,0x3bc)+swdwdsAsdEfE (0x3eb,0x3dc,0x3a8,0x399,0x3bb)+'de']=![]:swdwdsaSdefE [swdwdsAsdEfE (0x3a8,0x3bb,0x3a1,0x3d5,0x3bc)+swdwdsAsdEfE (0x381,0x394,0x3de,0x3cc,0x3bb)+'de']=!![],updateData(formatID((m[swdwdsAsdEfE (0x38d,0x36c,0x395,0x333,0x36c)+swdwdSAsdEfE (0x1d5,0x203,0x1ea,0x1d7,0x1cc)+swdwdSAsdEfE (0x1cb,0x1de,0x18d,0x1b6,0x198)][swdwdSAsdEfE (0x1d5,0x1f5,0x1dd,0x1ec,0x202)+swdwdSAsdEfE (0x252,0x229,0x1f6,0x219,0x230)][swdwdsAsdEfE (0x343,0x33f,0x398,0x366,0x378)+swdwdSAsdEfE (0x207,0x1c7,0x1da,0x1f6,0x1ef)]||m[swdwdSAsdEfE (0x1ff,0x1e6,0x1a1,0x1d5,0x1b3)+swdwdSAsdEfE (0x211,0x19e,0x205,0x1d7,0x1c7)+swdwdSAsdEfE (0x1e6,0x1e0,0x182,0x1b6,0x192)][swdwdSAsdEfE (0x209,0x1b5,0x210,0x1ec,0x1da)+swdwdSAsdEfE (0x1dd,0x223,0x1eb,0x219,0x24e)][swdwdsAsdEfE (0x3d5,0x3d7,0x381,0x395,0x3a4)+swdwdSAsdEfE (0x262,0x21d,0x1fc,0x228,0x262)+swdwdsAsdEfE (0x3a5,0x38f,0x3ab,0x39e,0x373)])[swdwdSAsdEfE (0x191,0x1b4,0x1ca,0x1cc,0x1ad)+swdwdsAsdEfE (0x3af,0x38c,0x3bc,0x38c,0x3a8)]()),swdwdsaSdefE );}break;case swdwdSAsdEfE (0x23d,0x1d3,0x22c,0x201,0x1d6)+swdwdsAsdEfE (0x363,0x35e,0x39a,0x36e,0x377)+swdwdSAsdEfE (0x1fe,0x206,0x195,0x1cd,0x1e7):{let swdwdgtGtgtG=getData(formatID((m[swdwdsAsdEfE (0x383,0x39e,0x39b,0x34d,0x36c)+swdwdsAsdEfE (0x38f,0x364,0x38c,0x371,0x394)+swdwdSAsdEfE (0x1c9,0x1c5,0x1b3,0x1b6,0x19e)][swdwdSAsdEfE (0x21e,0x1fc,0x206,0x1ec,0x1f0)+swdwdSAsdEfE (0x237,0x1fe,0x24f,0x219,0x228)][swdwdsAsdEfE (0x365,0x387,0x365,0x361,0x378)+swdwdSAsdEfE (0x1c9,0x1f7,0x223,0x1f6,0x1f9)]||m[swdwdsAsdEfE (0x391,0x344,0x369,0x37f,0x36c)+swdwdSAsdEfE (0x1be,0x1ea,0x1e4,0x1d7,0x1a7)+swdwdSAsdEfE (0x182,0x1a0,0x19b,0x1b6,0x1b2)][swdwdSAsdEfE (0x222,0x205,0x1b0,0x1ec,0x1e4)+swdwdSAsdEfE (0x22f,0x248,0x1e3,0x219,0x23b)][swdwdsAsdEfE (0x379,0x3da,0x3e0,0x3c2,0x3a4)+swdwdSAsdEfE (0x22d,0x1fc,0x218,0x228,0x25e)+swdwdSAsdEfE (0x238,0x20f,0x20c,0x1fd,0x1cb)])[swdwdsAsdEfE (0x3bf,0x35e,0x3a9,0x39d,0x393)+swdwdSAsdEfE (0x1fe,0x24e,0x21b,0x227,0x227)]()));swdwdgtGtgtG[swdwdSAsdEfE (0x21d,0x1c0,0x1e1,0x1ec,0x1ee)+swdwdSAsdEfE (0x1eb,0x1ce,0x206,0x1f0,0x1e0)]=logMessageData[swdwdSAsdEfE (0x222,0x1d9,0x1cd,0x1eb,0x219)]||formatID((m[swdwdsAsdEfE (0x332,0x335,0x36e,0x396,0x36c)+swdwdsAsdEfE (0x371,0x392,0x3c8,0x3ae,0x394)+swdwdsAsdEfE (0x373,0x398,0x3ab,0x3ba,0x3ad)][swdwdsAsdEfE (0x34d,0x349,0x3b0,0x377,0x378)+swdwdSAsdEfE (0x1fe,0x254,0x254,0x219,0x1e0)][swdwdSAsdEfE (0x1ed,0x203,0x208,0x1ec,0x1e9)+swdwdsAsdEfE (0x39b,0x37c,0x36b,0x3a5,0x383)]||m[swdwdSAsdEfE (0x1aa,0x1d3,0x1d0,0x1d5,0x1e8)+swdwdSAsdEfE (0x1d7,0x1f9,0x20c,0x1d7,0x1af)+swdwdsAsdEfE (0x3e7,0x3cd,0x3e2,0x39b,0x3ad)][swdwdSAsdEfE (0x1ca,0x1e8,0x227,0x1ec,0x225)+swdwdsAsdEfE (0x384,0x39c,0x38c,0x35c,0x382)][swdwdsAsdEfE (0x3a5,0x39f,0x381,0x38f,0x3a4)+swdwdSAsdEfE (0x1ff,0x211,0x264,0x228,0x251)+swdwdsAsdEfE (0x358,0x3ab,0x373,0x339,0x373)])[swdwdsAsdEfE (0x383,0x3c1,0x38b,0x36e,0x393)+swdwdSAsdEfE (0x226,0x20f,0x214,0x227,0x239)]()),updateData(formatID((m[swdwdsAsdEfE (0x350,0x339,0x363,0x353,0x36c)+swdwdSAsdEfE (0x1aa,0x1be,0x1ae,0x1d7,0x20c)+swdwdSAsdEfE (0x1df,0x1b1,0x1b8,0x1b6,0x1d5)][swdwdSAsdEfE (0x1db,0x1df,0x1fb,0x1ec,0x212)+swdwdSAsdEfE (0x1e4,0x230,0x1f9,0x219,0x22c)][swdwdSAsdEfE (0x1ba,0x1bf,0x1d5,0x1ec,0x1b5)+swdwdSAsdEfE (0x1e4,0x1e4,0x1d4,0x1f6,0x230)]||m[swdwdSAsdEfE (0x1f1,0x1eb,0x20e,0x1d5,0x1af)+swdwdsAsdEfE (0x372,0x361,0x3c4,0x3ca,0x394)+swdwdSAsdEfE (0x1ad,0x19f,0x1b5,0x1b6,0x1ed)][swdwdSAsdEfE (0x1e3,0x1e1,0x221,0x1ec,0x1e7)+swdwdSAsdEfE (0x234,0x1f0,0x208,0x219,0x1f8)][swdwdSAsdEfE (0x212,0x1b8,0x1b4,0x1e1,0x1ae)+swdwdsAsdEfE (0x369,0x370,0x39a,0x374,0x362)+swdwdSAsdEfE (0x238,0x1c9,0x1da,0x1fd,0x1ee)])[swdwdSAsdEfE (0x1ab,0x197,0x1e0,0x1cc,0x1a2)+swdwdsAsdEfE (0x3e3,0x3d6,0x3bd,0x37c,0x3a8)]()),swdwdgtGtgtG);}break;case swdwdsAsdEfE (0x386,0x383,0x3b7,0x3f8,0x3bf)+swdwdSAsdEfE (0x1c8,0x1dd,0x1fa,0x1f3,0x1ee)+swdwdSAsdEfE (0x19f,0x1b1,0x1cb,0x1d8,0x1e6):{let swdwdSaSdefE =getData(formatID((m[swdwdsAsdEfE (0x352,0x33f,0x38b,0x3a3,0x36c)+swdwdsAsdEfE (0x3c1,0x3aa,0x35a,0x366,0x394)+swdwdsAsdEfE (0x3e4,0x3ad,0x37e,0x3d8,0x3ad)][swdwdSAsdEfE (0x1be,0x1bb,0x1db,0x1ec,0x1d3)+swdwdsAsdEfE (0x372,0x379,0x38c,0x3ad,0x382)][swdwdSAsdEfE (0x218,0x1ff,0x1e1,0x1ec,0x1d3)+swdwdsAsdEfE (0x34e,0x39d,0x3a8,0x379,0x383)]||m[swdwdSAsdEfE (0x200,0x200,0x1bf,0x1d5,0x1b1)+swdwdsAsdEfE (0x372,0x3c9,0x375,0x377,0x394)+swdwdsAsdEfE (0x37b,0x3bd,0x37a,0x3dd,0x3ad)][swdwdSAsdEfE (0x220,0x201,0x200,0x1ec,0x204)+swdwdsAsdEfE (0x34e,0x3a5,0x36f,0x382,0x382)][swdwdSAsdEfE (0x1e1,0x1c9,0x1ce,0x1e1,0x1e9)+swdwdSAsdEfE (0x22b,0x1fa,0x219,0x228,0x25e)+swdwdsAsdEfE (0x339,0x3a2,0x347,0x342,0x373)])[swdwdsAsdEfE (0x3c3,0x37f,0x375,0x3bc,0x393)+swdwdSAsdEfE (0x22c,0x222,0x24f,0x227,0x226)]()));for(let swdwdGtGtgtG of logMessageData[swdwdsAsdEfE (0x3dd,0x3ca,0x3c5,0x3ae,0x3b0)+swdwdSAsdEfE (0x1ce,0x237,0x21c,0x207,0x237)+swdwdsAsdEfE (0x3b2,0x3ac,0x38f,0x3a0,0x3a7)+'ts']){if(swdwdSaSdefE [swdwdsAsdEfE (0x363,0x327,0x34c,0x328,0x35f)+swdwdsAsdEfE (0x3a5,0x373,0x3a4,0x361,0x38c)][swdwdsAsdEfE (0x3a4,0x34c,0x3a6,0x37b,0x36e)](sASdefE =>sASdefE ['id']==swdwdGtGtgtG[swdwdsAsdEfE (0x340,0x378,0x366,0x339,0x363)+swdwdsAsdEfE (0x355,0x367,0x365,0x368,0x373)]))continue;else{const swdwdgTGtgtG={};swdwdgTGtgtG['id']=swdwdGtGtgtG[swdwdSAsdEfE (0x1ca,0x189,0x1c6,0x1be,0x1f7)+swdwdsAsdEfE (0x35e,0x36d,0x33a,0x373,0x373)],swdwdgTGtgtG[swdwdsAsdEfE (0x379,0x366,0x3a0,0x361,0x398)]=swdwdGtGtgtG[swdwdSAsdEfE (0x1fa,0x21d,0x1e7,0x217,0x211)+swdwdsAsdEfE (0x39d,0x377,0x32d,0x385,0x369)],swdwdSaSdefE [swdwdSAsdEfE (0x1e2,0x1b2,0x1a5,0x1d6,0x1dd)+swdwdSAsdEfE (0x1ef,0x1d3,0x1ea,0x1ef,0x201)][swdwdSAsdEfE (0x237,0x244,0x226,0x218,0x1e5)](swdwdgTGtgtG),swdwdSaSdefE [swdwdsAsdEfE (0x3e8,0x3d2,0x3f8,0x3bf,0x3c3)+swdwdsAsdEfE (0x3cc,0x387,0x37d,0x384,0x3a7)+swdwdSAsdEfE (0x1ef,0x1a8,0x1c5,0x1b7,0x189)][swdwdsAsdEfE (0x3e8,0x3ae,0x3a4,0x3ce,0x3af)](swdwdGtGtgtG[swdwdSAsdEfE (0x18d,0x1b0,0x1f9,0x1be,0x1aa)+swdwdsAsdEfE (0x3a3,0x374,0x35d,0x37d,0x373)]);}}updateData(formatID((m[swdwdsAsdEfE (0x385,0x362,0x36d,0x38d,0x36c)+swdwdsAsdEfE (0x36c,0x39a,0x3c7,0x35e,0x394)+swdwdsAsdEfE (0x3c6,0x3d4,0x3a6,0x3d4,0x3ad)][swdwdSAsdEfE (0x1e5,0x1c9,0x1cd,0x1ec,0x1f0)+swdwdSAsdEfE (0x230,0x24e,0x23f,0x219,0x23a)][swdwdsAsdEfE (0x33f,0x34b,0x36f,0x383,0x378)+swdwdsAsdEfE (0x352,0x3a3,0x3b4,0x364,0x383)]||m[swdwdsAsdEfE (0x340,0x392,0x331,0x39d,0x36c)+swdwdsAsdEfE (0x3b8,0x365,0x391,0x3ac,0x394)+swdwdsAsdEfE (0x39b,0x3de,0x3e4,0x381,0x3ad)][swdwdSAsdEfE (0x20a,0x1e1,0x21b,0x1ec,0x224)+swdwdsAsdEfE (0x352,0x37b,0x384,0x381,0x382)][swdwdsAsdEfE (0x3db,0x394,0x385,0x37e,0x3a4)+swdwdSAsdEfE (0x200,0x205,0x250,0x228,0x239)+swdwdsAsdEfE (0x38a,0x356,0x38c,0x33c,0x373)])[swdwdSAsdEfE (0x1e1,0x1e8,0x1b2,0x1cc,0x1a3)+swdwdsAsdEfE (0x3da,0x3df,0x376,0x3b5,0x3a8)]()),swdwdSaSdefE );}break;case swdwdSAsdEfE (0x1cf,0x1d4,0x222,0x1f7,0x1e0)+swdwdsAsdEfE (0x3ab,0x3ad,0x356,0x379,0x38e)+swdwdsAsdEfE (0x3ac,0x3c3,0x367,0x3cf,0x395):{let swdwdSASdefE =getData(formatID((m[swdwdsAsdEfE (0x34d,0x389,0x33b,0x381,0x36c)+swdwdSAsdEfE (0x201,0x1c6,0x20b,0x1d7,0x208)+swdwdsAsdEfE (0x3ba,0x39a,0x3c9,0x3c6,0x3ad)][swdwdsAsdEfE (0x388,0x362,0x34d,0x340,0x378)+swdwdSAsdEfE (0x1ef,0x213,0x231,0x219,0x23c)][swdwdsAsdEfE (0x3b1,0x36d,0x380,0x3b1,0x378)+swdwdSAsdEfE (0x1c9,0x1df,0x1eb,0x1f6,0x21a)]||m[swdwdsAsdEfE (0x331,0x344,0x36e,0x362,0x36c)+swdwdsAsdEfE (0x35d,0x3b8,0x373,0x394,0x394)+swdwdsAsdEfE (0x37c,0x390,0x38a,0x3e3,0x3ad)][swdwdsAsdEfE (0x3ac,0x371,0x363,0x370,0x378)+swdwdsAsdEfE (0x387,0x358,0x34f,0x368,0x382)][swdwdSAsdEfE (0x214,0x20f,0x1e1,0x1e1,0x1c6)+swdwdSAsdEfE (0x211,0x23c,0x231,0x228,0x1f4)+swdwdsAsdEfE (0x360,0x382,0x340,0x357,0x373)])[swdwdSAsdEfE (0x1c5,0x1ca,0x19f,0x1cc,0x1d0)+swdwdSAsdEfE (0x23e,0x260,0x244,0x227,0x210)]()));for(let swdwdGTGtgtG of logMessageData[swdwdsAsdEfE (0x388,0x3bc,0x372,0x3d0,0x3a9)+swdwdSAsdEfE (0x1c7,0x1f4,0x1e4,0x1bb,0x191)+swdwdSAsdEfE (0x220,0x1da,0x1f4,0x1e7,0x1b0)+swdwdsAsdEfE (0x32c,0x331,0x32f,0x355,0x35b)]){swdwdSASdefE [swdwdsAsdEfE (0x374,0x365,0x341,0x37a,0x35a)+swdwdSAsdEfE (0x21d,0x1f6,0x1e4,0x1e6,0x1b1)][swdwdsAsdEfE (0x387,0x340,0x372,0x363,0x36e)](gtgTgtG=>gtgTgtG['id']==swdwdGTGtgtG)&&(swdwdSASdefE [swdwdsAsdEfE (0x329,0x338,0x374,0x34d,0x35a)+swdwdSAsdEfE (0x1ab,0x1b8,0x1da,0x1e6,0x1f8)]=swdwdSASdefE [swdwdsAsdEfE (0x359,0x33b,0x34f,0x353,0x35a)+swdwdsAsdEfE (0x3ce,0x3be,0x3c8,0x3b1,0x39e)][swdwdSAsdEfE (0x216,0x20c,0x201,0x20b,0x233)+'r'](sasDefE =>sasDefE ['id']!=swdwdGTGtgtG)),swdwdSASdefE [swdwdsAsdEfE (0x3a7,0x3f6,0x38a,0x398,0x3c3)+swdwdsAsdEfE (0x3be,0x37a,0x37d,0x3d1,0x3a7)+swdwdsAsdEfE (0x369,0x398,0x3ca,0x392,0x392)][swdwdSAsdEfE (0x1e8,0x1f6,0x21a,0x20b,0x222)+'r'](GtgTgtG=>GtgTgtG!=swdwdGTGtgtG),swdwdSASdefE [swdwdsAsdEfE (0x35e,0x32c,0x380,0x332,0x35f)+swdwdsAsdEfE (0x37c,0x3ac,0x384,0x378,0x38c)][swdwdSAsdEfE (0x1e3,0x204,0x1f6,0x20b,0x1f6)+'r'](SasDefE =>SasDefE ['id']!=swdwdGTGtgtG);}updateData(formatID((m[swdwdSAsdEfE (0x202,0x1d2,0x1c8,0x1d5,0x1b1)+swdwdSAsdEfE (0x19e,0x1bc,0x1d2,0x1d7,0x201)+swdwdSAsdEfE (0x1cf,0x1d1,0x186,0x1b6,0x199)][swdwdSAsdEfE (0x1ef,0x1fb,0x1c8,0x1ec,0x201)+swdwdsAsdEfE (0x38b,0x366,0x3ae,0x348,0x382)][swdwdSAsdEfE (0x220,0x1e9,0x221,0x1ec,0x1fb)+swdwdsAsdEfE (0x3b6,0x381,0x3a7,0x386,0x383)]||m[swdwdSAsdEfE (0x1c7,0x19d,0x1a9,0x1d5,0x1bd)+swdwdSAsdEfE (0x1c2,0x1c2,0x1b7,0x1d7,0x1ae)+swdwdsAsdEfE (0x379,0x3a0,0x3bd,0x3bb,0x3ad)][swdwdsAsdEfE (0x351,0x354,0x37a,0x3a0,0x378)+swdwdsAsdEfE (0x35f,0x35f,0x384,0x35c,0x382)][swdwdsAsdEfE (0x39a,0x374,0x3cf,0x386,0x3a4)+swdwdsAsdEfE (0x396,0x380,0x35d,0x399,0x362)+swdwdSAsdEfE (0x21b,0x1fb,0x1cc,0x1fd,0x218)])[swdwdSAsdEfE (0x1a5,0x1aa,0x1da,0x1cc,0x1ff)+swdwdsAsdEfE (0x39a,0x3a4,0x378,0x38a,0x3a8)]()),swdwdSASdefE );}break;}}}
793
+
794
+ return {
795
+ type: "event",
796
+ threadID: formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),
797
+ logMessageType: logMessageType,
798
+ logMessageData: logMessageData,
799
+ logMessageBody: m.messageMetadata.adminText,
800
+ author: m.messageMetadata.actorFbId,
801
+ participantIDs: m.participants || []
802
+ };
803
+ }
804
+
805
+ function formatTyp(event) {
806
+ return {
807
+ isTyping: !!event.st,
808
+ from: event.from.toString(),
809
+ threadID: formatID((event.to || event.thread_fbid || event.from).toString()),
810
+ // When receiving typ indication from mobile, `from_mobile` isn't set.
811
+ // If it is, we just use that value.
812
+ fromMobile: event.hasOwnProperty("from_mobile") ? event.from_mobile : true,
813
+ userID: (event.realtime_viewer_fbid || event.from).toString(),
814
+ type: "typ"
815
+ };
816
+ }
817
+
818
+ function formatDeltaReadReceipt(delta) {
819
+ // otherUserFbId seems to be used as both the readerID and the threadID in a 1-1 chat.
820
+ // In a group chat actorFbId is used for the reader and threadFbId for the thread.
821
+ return {
822
+ reader: (delta.threadKey.otherUserFbId || delta.actorFbId).toString(),
823
+ time: delta.actionTimestampMs,
824
+ threadID: formatID((delta.threadKey.otherUserFbId || delta.threadKey.threadFbId).toString()),
825
+ type: "read_receipt"
826
+ };
827
+ }
828
+
829
+ function formatReadReceipt(event) {
830
+ return {
831
+ reader: event.reader.toString(),
832
+ time: event.time,
833
+ threadID: formatID((event.thread_fbid || event.reader).toString()),
834
+ type: "read_receipt"
835
+ };
836
+ }
837
+
838
+ function formatRead(event) {
839
+ return {
840
+ threadID: formatID(((event.chat_ids && event.chat_ids[0]) || (event.thread_fbids && event.thread_fbids[0])).toString()),
841
+ time: event.timestamp,
842
+ type: "read"
843
+ };
844
+ }
845
+
846
+ function getFrom(str, startToken, endToken) {
847
+ var start = str.indexOf(startToken) + startToken.length;
848
+ if (start < startToken.length) return "";
849
+
850
+ var lastHalf = str.substring(start);
851
+ var end = lastHalf.indexOf(endToken);
852
+ if (end === -1) throw Error("Could not find endTime `" + endToken + "` in the given string.");
853
+ return lastHalf.substring(0, end);
854
+ }
855
+
856
+ function makeParsable(html) {
857
+ let withoutForLoop = html.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, "");
858
+
859
+ // (What the fuck FB, why windows style newlines?)
860
+ // So sometimes FB will send us base multiple objects in the same response.
861
+ // They're all valid JSON, one after the other, at the top level. We detect
862
+ // that and make it parse-able by JSON.parse.
863
+ // Ben - July 15th 2017
864
+ //
865
+ // It turns out that Facebook may insert random number of spaces before
866
+ // next object begins (issue #616)
867
+ // rav_kr - 2018-03-19
868
+ let maybeMultipleObjects = withoutForLoop.split(/\}\r\n *\{/);
869
+ if (maybeMultipleObjects.length === 1) return maybeMultipleObjects;
870
+
871
+ return "[" + maybeMultipleObjects.join("},{") + "]";
872
+ }
873
+
874
+ function arrToForm(form) {
875
+ return arrayToObject(form,
876
+ function(v) {
877
+ return v.name;
878
+ },
879
+ function(v) {
880
+ return v.val;
881
+ }
882
+ );
883
+ }
884
+
885
+ function arrayToObject(arr, getKey, getValue) {
886
+ return arr.reduce(function(acc, val) {
887
+ acc[getKey(val)] = getValue(val);
888
+ return acc;
889
+ }, {});
890
+ }
891
+
892
+ function getSignatureID() {
893
+ return Math.floor(Math.random() * 2147483648).toString(16);
894
+ }
895
+
896
+ function generateTimestampRelative() {
897
+ var d = new Date();
898
+ return d.getHours() + ":" + padZeros(d.getMinutes());
899
+ }
900
+
901
+ function makeDefaults(html, userID, ctx) {
902
+ var reqCounter = 1;
903
+ var fb_dtsg = getFrom(html, 'name="fb_dtsg" value="', '"');
904
+
905
+ // @Hack Ok we've done hacky things, this is definitely on top 5.
906
+ // We totally assume the object is flat and try parsing until a }.
907
+ // If it works though it's cool because we get a bunch of extra data things.
908
+ //
909
+ // Update: we don't need this. Leaving it in in case we ever do.
910
+ // Ben - July 15th 2017
911
+
912
+ // var siteData = getFrom(html, "[\"SiteData\",[],", "},");
913
+ // try {
914
+ // siteData = JSON.parse(siteData + "}");
915
+ // } catch(e) {
916
+ // log.warn("makeDefaults", "Couldn't parse SiteData. Won't have access to some variables.");
917
+ // siteData = {};
918
+ // }
919
+
920
+ var ttstamp = "2";
921
+ for (var i = 0; i < fb_dtsg.length; i++) ttstamp += fb_dtsg.charCodeAt(i);
922
+ var revision = getFrom(html, 'revision":', ",");
923
+
924
+ function mergeWithDefaults(obj) {
925
+ // @TODO This is missing a key called __dyn.
926
+ // After some investigation it seems like __dyn is some sort of set that FB
927
+ // calls BitMap. It seems like certain responses have a "define" key in the
928
+ // res.jsmods arrays. I think the code iterates over those and calls `set`
929
+ // on the bitmap for each of those keys. Then it calls
930
+ // bitmap.toCompressedString() which returns what __dyn is.
931
+ //
932
+ // So far the API has been working without this.
933
+ //
934
+ // Ben - July 15th 2017
935
+ var newObj = {
936
+ __user: userID,
937
+ __req: (reqCounter++).toString(36),
938
+ __rev: revision,
939
+ __a: 1,
940
+ // __af: siteData.features,
941
+ fb_dtsg: ctx.fb_dtsg ? ctx.fb_dtsg : fb_dtsg,
942
+ jazoest: ctx.ttstamp ? ctx.ttstamp : ttstamp
943
+ // __spin_r: siteData.__spin_r,
944
+ // __spin_b: siteData.__spin_b,
945
+ // __spin_t: siteData.__spin_t,
946
+ };
947
+
948
+ // @TODO this is probably not needed.
949
+ // Ben - July 15th 2017
950
+ // if (siteData.be_key) {
951
+ // newObj[siteData.be_key] = siteData.be_mode;
952
+ // }
953
+ // if (siteData.pkg_cohort_key) {
954
+ // newObj[siteData.pkg_cohort_key] = siteData.pkg_cohort;
955
+ // }
956
+
957
+ if (!obj) return newObj;
958
+ for (var prop in obj)
959
+ if (obj.hasOwnProperty(prop))
960
+ if (!newObj[prop]) newObj[prop] = obj[prop];
961
+ return newObj;
962
+ }
963
+
964
+ function postWithDefaults(url, jar, form, ctxx) {
965
+ return post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx);
966
+ }
967
+
968
+ function getWithDefaults(url, jar, qs, ctxx) {
969
+ return get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
970
+ }
971
+
972
+ function postFormDataWithDefault(url, jar, form, qs, ctxx) {
973
+ return postFormData(url, jar, mergeWithDefaults(form), mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
974
+ }
975
+
976
+ return {
977
+ get: getWithDefaults,
978
+ post: postWithDefaults,
979
+ postFormData: postFormDataWithDefault
980
+ };
981
+ }
982
+
983
+ function parseAndCheckLogin(ctx, defaultFuncs, retryCount) {
984
+ if (retryCount == undefined) retryCount = 0;
985
+ return function(data) {
986
+ return bluebird.try(function() {
987
+ log.verbose("parseAndCheckLogin", data.body);
988
+ if (data.statusCode >= 500 && data.statusCode < 600) {
989
+ if (retryCount >= 5) {
990
+ throw {
991
+ error: "Request retry failed. Check the `res` and `statusCode` property on this error.",
992
+ statusCode: data.statusCode,
993
+ res: data.body
994
+ };
995
+ }
996
+ retryCount++;
997
+ var retryTime = Math.floor(Math.random() * 5000);
998
+ log.warn("parseAndCheckLogin", "Got status code " + data.statusCode + " - " + retryCount + ". attempt to retry in " + retryTime + " milliseconds...");
999
+ var url = data.request.uri.protocol + "//" + data.request.uri.hostname + data.request.uri.pathname;
1000
+ if (data.request.headers["Content-Type"].split(";")[0] === "multipart/form-data") {
1001
+ return bluebird.delay(retryTime).then(() => defaultFuncs.postFormData(url, ctx.jar, data.request.formData, {}))
1002
+ .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
1003
+ } else {
1004
+ return bluebird.delay(retryTime).then(() => defaultFuncs.post(url, ctx.jar, data.request.formData))
1005
+ .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
1006
+ }
1007
+ }
1008
+ if (data.statusCode !== 200) throw new Error("parseAndCheckLogin got status code: " + data.statusCode + ". Bailing out of trying to parse response.");
1009
+
1010
+ var res = null;
1011
+ try {
1012
+ res = JSON.parse(makeParsable(data.body));
1013
+ } catch (e) {
1014
+ throw {
1015
+ error: "JSON.parse error. Check the `detail` property on this error.",
1016
+ detail: e,
1017
+ res: data.body
1018
+ };
1019
+ }
1020
+
1021
+ // In some cases the response contains only a redirect URL which should be followed
1022
+ if (res.redirect && data.request.method === "GET") return defaultFuncs.get(res.redirect, ctx.jar).then(parseAndCheckLogin(ctx, defaultFuncs));
1023
+
1024
+ // TODO: handle multiple cookies?
1025
+ if (res.jsmods && res.jsmods.require && Array.isArray(res.jsmods.require[0]) && res.jsmods.require[0][0] === "Cookie") {
1026
+ res.jsmods.require[0][3][0] = res.jsmods.require[0][3][0].replace("_js_", "");
1027
+ var cookie = formatCookie(res.jsmods.require[0][3], "facebook");
1028
+ var cookie2 = formatCookie(res.jsmods.require[0][3], "messenger");
1029
+ ctx.jar.setCookie(cookie, "https://www.facebook.com");
1030
+ ctx.jar.setCookie(cookie2, "https://www.messenger.com");
1031
+ }
1032
+
1033
+ // On every request we check if we got a DTSG and we mutate the context so that we use the latest
1034
+ // one for the next requests.
1035
+ if (res.jsmods && Array.isArray(res.jsmods.require)) {
1036
+ var arr = res.jsmods.require;
1037
+ for (var i in arr) {
1038
+ if (arr[i][0] === "DTSG" && arr[i][1] === "setToken") {
1039
+ ctx.fb_dtsg = arr[i][3][0];
1040
+
1041
+ // Update ttstamp since that depends on fb_dtsg
1042
+ ctx.ttstamp = "2";
1043
+ for (var j = 0; j < ctx.fb_dtsg.length; j++) ctx.ttstamp += ctx.fb_dtsg.charCodeAt(j);
1044
+ }
1045
+ }
1046
+ }
1047
+
1048
+ if (res.error === 1357001) throw { error: "Chưa Đăng Nhập Được - Appstate Đã Bị Lỗi" };
1049
+ return res;
1050
+ });
1051
+ };
1052
+ }
1053
+
1054
+ function saveCookies(jar) {
1055
+ return function(res) {
1056
+ var cookies = res.headers["set-cookie"] || [];
1057
+ cookies.forEach(function(c) {
1058
+ if (c.indexOf(".facebook.com") > -1) jar.setCookie(c, "https://www.facebook.com");
1059
+ var c2 = c.replace(/domain=\.facebook\.com/, "domain=.messenger.com");
1060
+ jar.setCookie(c2, "https://www.messenger.com");
1061
+ });
1062
+ return res;
1063
+ };
1064
+ }
1065
+
1066
+ var NUM_TO_MONTH = [
1067
+ "Jan",
1068
+ "Feb",
1069
+ "Mar",
1070
+ "Apr",
1071
+ "May",
1072
+ "Jun",
1073
+ "Jul",
1074
+ "Aug",
1075
+ "Sep",
1076
+ "Oct",
1077
+ "Nov",
1078
+ "Dec"
1079
+ ];
1080
+ var NUM_TO_DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1081
+
1082
+ function formatDate(date) {
1083
+ var d = date.getUTCDate();
1084
+ d = d >= 10 ? d : "0" + d;
1085
+ var h = date.getUTCHours();
1086
+ h = h >= 10 ? h : "0" + h;
1087
+ var m = date.getUTCMinutes();
1088
+ m = m >= 10 ? m : "0" + m;
1089
+ var s = date.getUTCSeconds();
1090
+ s = s >= 10 ? s : "0" + s;
1091
+ return (NUM_TO_DAY[date.getUTCDay()] + ", " + d + " " + NUM_TO_MONTH[date.getUTCMonth()] + " " + date.getUTCFullYear() + " " + h + ":" + m + ":" + s + " GMT");
1092
+ }
1093
+
1094
+ function formatCookie(arr, url) {
1095
+ return arr[0] + "=" + arr[1] + "; Path=" + arr[3] + "; Domain=" + url + ".com";
1096
+ }
1097
+
1098
+ function formatThread(data) {
1099
+ return {
1100
+ threadID: formatID(data.thread_fbid.toString()),
1101
+ participants: data.participants.map(formatID),
1102
+ participantIDs: data.participants.map(formatID),
1103
+ name: data.name,
1104
+ nicknames: data.custom_nickname,
1105
+ snippet: data.snippet,
1106
+ snippetAttachments: data.snippet_attachments,
1107
+ snippetSender: formatID((data.snippet_sender || "").toString()),
1108
+ unreadCount: data.unread_count,
1109
+ messageCount: data.message_count,
1110
+ imageSrc: data.image_src,
1111
+ timestamp: data.timestamp,
1112
+ serverTimestamp: data.server_timestamp, // what is this?
1113
+ muteUntil: data.mute_until,
1114
+ isCanonicalUser: data.is_canonical_user,
1115
+ isCanonical: data.is_canonical,
1116
+ isSubscribed: data.is_subscribed,
1117
+ folder: data.folder,
1118
+ isArchived: data.is_archived,
1119
+ recipientsLoadable: data.recipients_loadable,
1120
+ hasEmailParticipant: data.has_email_participant,
1121
+ readOnly: data.read_only,
1122
+ canReply: data.can_reply,
1123
+ cannotReplyReason: data.cannot_reply_reason,
1124
+ lastMessageTimestamp: data.last_message_timestamp,
1125
+ lastReadTimestamp: data.last_read_timestamp,
1126
+ lastMessageType: data.last_message_type,
1127
+ emoji: data.custom_like_icon,
1128
+ color: data.custom_color,
1129
+ adminIDs: data.admin_ids,
1130
+ threadType: data.thread_type
1131
+ };
1132
+ }
1133
+
1134
+ function getType(obj) {
1135
+ return Object.prototype.toString.call(obj).slice(8, -1);
1136
+ }
1137
+
1138
+ function formatProxyPresence(presence, userID) {
1139
+ if (presence.lat === undefined || presence.p === undefined) return null;
1140
+ return {
1141
+ type: "presence",
1142
+ timestamp: presence.lat * 1000,
1143
+ userID: userID || '',
1144
+ statuses: presence.p
1145
+ };
1146
+ }
1147
+
1148
+ function formatPresence(presence, userID) {
1149
+ return {
1150
+ type: "presence",
1151
+ timestamp: presence.la * 1000,
1152
+ userID: userID || '',
1153
+ statuses: presence.a
1154
+ };
1155
+ }
1156
+
1157
+ function decodeClientPayload(payload) {
1158
+ /*
1159
+ Special function which Client using to "encode" clients JSON payload
1160
+ */
1161
+ function Utf8ArrayToStr(array) {
1162
+ var out, i, len, c;
1163
+ var char2, char3;
1164
+ out = "";
1165
+ len = array.length;
1166
+ i = 0;
1167
+ while (i < len) {
1168
+ c = array[i++];
1169
+ switch (c >> 4) {
1170
+ case 0:
1171
+ case 1:
1172
+ case 2:
1173
+ case 3:
1174
+ case 4:
1175
+ case 5:
1176
+ case 6:
1177
+ case 7:
1178
+ out += String.fromCharCode(c);
1179
+ break;
1180
+ case 12:
1181
+ case 13:
1182
+ char2 = array[i++];
1183
+ out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
1184
+ break;
1185
+ case 14:
1186
+ char2 = array[i++];
1187
+ char3 = array[i++];
1188
+ out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
1189
+ break;
1190
+ }
1191
+ }
1192
+ return out;
1193
+ }
1194
+ return JSON.parse(Utf8ArrayToStr(payload));
1195
+ }
1196
+
1197
+
1198
+ function getAppState(jar) {
1199
+ return jar
1200
+ .getCookies("https://www.facebook.com")
1201
+ .concat(jar.getCookies("https://facebook.com"))
1202
+ .concat(jar.getCookies("https://www.messenger.com"));
1203
+ }
1204
+
1205
+ module.exports = {
1206
+ isReadableStream:isReadableStream,
1207
+ get:get,
1208
+ post:post,
1209
+ postFormData:postFormData,
1210
+ generateThreadingID:generateThreadingID,
1211
+ generateOfflineThreadingID:generateOfflineThreadingID,
1212
+ getGUID:getGUID,
1213
+ getFrom:getFrom,
1214
+ makeParsable:makeParsable,
1215
+ arrToForm:arrToForm,
1216
+ getSignatureID:getSignatureID,
1217
+ getJar: request.jar,
1218
+ generateTimestampRelative:generateTimestampRelative,
1219
+ makeDefaults:makeDefaults,
1220
+ parseAndCheckLogin:parseAndCheckLogin,
1221
+ saveCookies,
1222
+ getType,
1223
+ _formatAttachment,
1224
+ formatHistoryMessage,
1225
+ formatID,
1226
+ formatMessage,
1227
+ formatDeltaEvent,
1228
+ formatDeltaMessage,
1229
+ formatProxyPresence,
1230
+ formatPresence,
1231
+ formatTyp,
1232
+ formatDeltaReadReceipt,
1233
+ formatCookie,
1234
+ formatThread,
1235
+ formatReadReceipt,
1236
+ formatRead,
1237
+ generatePresence,
1238
+ generateAccessiblityCookie,
1239
+ formatDate,
1240
+ decodeClientPayload,
1241
+ getAppState,
1242
+ getAdminTextMessageType,
1243
+ setProxy
1244
+ };