fca-umaru-v1 40.1.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/.travis.yml +6 -0
  2. package/CHANGELOG.md +2 -0
  3. package/DOCS.md +1947 -0
  4. package/LICENSE-MIT +21 -0
  5. package/README.md +219 -0
  6. package/index.js +1 -0
  7. package/package.json +67 -0
  8. package/src/addExternalModule.js +1 -0
  9. package/src/addUserToGroup.js +1 -0
  10. package/src/changeAdminStatus.js +1 -0
  11. package/src/changeArchivedStatus.js +1 -0
  12. package/src/changeAvatar.js +1 -0
  13. package/src/changeBio.js +1 -0
  14. package/src/changeBlockedStatus.js +1 -0
  15. package/src/changeGroupImage.js +1 -0
  16. package/src/changeNickname.js +1 -0
  17. package/src/changeThreadColor.js +1 -0
  18. package/src/changeThreadEmoji.js +1 -0
  19. package/src/createNewGroup.js +1 -0
  20. package/src/createPoll.js +1 -0
  21. package/src/deleteMessage.js +1 -0
  22. package/src/deleteThread.js +1 -0
  23. package/src/forwardAttachment.js +1 -0
  24. package/src/getAccessToken.js +1 -0
  25. package/src/getCurrentUserID.js +1 -0
  26. package/src/getEmojiUrl.js +1 -0
  27. package/src/getFriendsList.js +1 -0
  28. package/src/getMessage.js +1 -0
  29. package/src/getThreadHistory.js +1 -0
  30. package/src/getThreadInfo.js +1 -0
  31. package/src/getThreadList.js +1 -0
  32. package/src/getThreadPictures.js +1 -0
  33. package/src/getUserID.js +1 -0
  34. package/src/getUserInfo.js +1 -0
  35. package/src/handleFriendRequest.js +1 -0
  36. package/src/handleMessageRequest.js +1 -0
  37. package/src/httpGet.js +1 -0
  38. package/src/httpPost.js +1 -0
  39. package/src/httpPostFormData.js +1 -0
  40. package/src/listenMqtt.js +1 -0
  41. package/src/logout.js +1 -0
  42. package/src/markAsDelivered.js +1 -0
  43. package/src/markAsRead.js +1 -0
  44. package/src/markAsReadAll.js +1 -0
  45. package/src/markAsSeen.js +1 -0
  46. package/src/muteThread.js +1 -0
  47. package/src/removeUserFromGroup.js +1 -0
  48. package/src/resolvePhotoUrl.js +1 -0
  49. package/src/searchForThread.js +1 -0
  50. package/src/sendMessage.js +1 -0
  51. package/src/sendTypingIndicator.js +1 -0
  52. package/src/setMessageReaction.js +1 -0
  53. package/src/setPostReaction.js +1 -0
  54. package/src/setTitle.js +1 -0
  55. package/src/threadColors.js +1 -0
  56. package/src/unfriend.js +1 -0
  57. package/src/unsendMessage.js +1 -0
  58. package/src/uploadAttachment.js +1 -0
  59. package/utils.js +1 -0
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog"),a=require("mqtt"),s=require("websocket-stream"),r=require("https-proxy-agent"),n=require("events"),i=function(){};let o={},l=function(){};const d=["/legacy_web","/webrtc","/rtc_multi","/onevc","/br_sr","/sr_res","/t_ms","/thread_typing","/orca_typing_notifications","/notify_disconnect","/orca_presence","/legacy_web_mtouch"];function g(t,n,i,g){const m=i.globalOptions.online,p=Math.floor(9007199254740991*Math.random())+1,h={u:i.i_userID||i.userID,s:p,chat_on:m,fg:!1,d:e.getGUID(),ct:"websocket",aid:"219994525426954",mqtt_sid:"",cp:3,ecp:10,st:[],pm:[],dc:"",no_auto_fg:!0,gas:null,pack:[],a:i.globalOptions.userAgent,aids:null},u=i.jar.getCookies("https://www.facebook.com").join("; ");let _;_=i.mqttEndpoint?i.mqttEndpoint+"&sid="+p:i.region?"wss://edge-chat.facebook.com/chat?region="+i.region.toLocaleLowerCase()+"&sid="+p:"wss://edge-chat.facebook.com/chat?sid="+p;const y={clientId:"mqttwsclient",protocolId:"MQIsdp",protocolVersion:3,username:JSON.stringify(h),clean:!0,wsOptions:{headers:{Cookie:u,Origin:"https://www.facebook.com","User-Agent":i.globalOptions.userAgent,Referer:"https://www.facebook.com/",Host:new URL(_).hostname},origin:"https://www.facebook.com",protocolVersion:13},keepalive:10,reschedulePings:!1};if(void 0!==i.globalOptions.proxy){const e=new r(i.globalOptions.proxy);y.wsOptions.agent=e}i.mqttClient=new a.Client((e=>s(_,y.wsOptions)),y);const b=i.mqttClient;b.on("error",(function(e){b.end(),i.globalOptions.autoReconnect?l():g({type:"stop_listen",error:"Connection refused: Server unavailable"},null)})),b.on("close",(function(){b.end(),t.post("https://www.facebook.com/api/graphqlbatch/",i.jar,o).then(e.parseAndCheckLogin(i,t)).then((t=>{if("Array"!=e.getType(t))throw{error:"Not logged in",res:t};g("Connection closed.")})).catch((t=>("Object"!=e.getType(t)||"Not logged in"!==t.error&&"Not logged in."!==t.error||(i.loggedIn=!1),g(t))))})),b.on("connect",(function(){let e;d.forEach((function(e){b.subscribe(e)}));const t={sync_api_version:10,max_deltas_able_to_process:1e3,delta_batch_size:500,encoding:"JSON",entity_fbid:i.i_userID||i.userID};i.syncToken?(e="/messenger_sync_get_diffs",t.last_seq_id=i.lastSeqId,t.sync_token=i.syncToken):(e="/messenger_sync_create_queue",t.initial_titan_sequence_id=i.lastSeqId,t.device_params=null),b.publish(e,JSON.stringify(t),{qos:1,retain:!1}),b.publish("/foreground_state",JSON.stringify({foreground:m}),{qos:1}),b.publish("/set_client_settings",JSON.stringify({make_user_available_when_in_foreground:!0}),{qos:1});const a=setTimeout((function(){b.end(),l()}),5e3);i.tmsWait=function(){clearTimeout(a),i.globalOptions.emitReady&&g({type:"ready",error:null}),delete i.tmsWait}})),b.on("message",(function(a,s,r){let o=Buffer.isBuffer(s)?Buffer.from(s).toString():s;try{o=JSON.parse(o)}catch(e){o={}}if("jewel_requests_add"===o.type)g(null,{type:"friend_request_received",actorFbId:o.from.toString(),timestamp:Date.now().toString()});else if("jewel_requests_remove_old"===o.type)g(null,{type:"friend_request_cancel",actorFbId:o.from.toString(),timestamp:Date.now().toString()});else if("/t_ms"===a){i.tmsWait&&"function"==typeof i.tmsWait&&i.tmsWait(),o.firstDeltaSeqId&&o.syncToken&&(i.lastSeqId=o.firstDeltaSeqId,i.syncToken=o.syncToken),o.lastIssuedSeqId&&(i.lastSeqId=parseInt(o.lastIssuedSeqId));for(const e in o.deltas)c(t,n,i,g,{delta:o.deltas[e]})}else if("/thread_typing"===a||"/orca_typing_notifications"===a){const t={type:"typ",isTyping:!!o.state,from:o.sender_fbid.toString(),threadID:e.formatID((o.thread||o.sender_fbid).toString())};g(null,t)}else if("/orca_presence"===a&&!i.globalOptions.updatePresence)for(const e in o.list){const t=o.list[e],a={type:"presence",userID:t.u.toString(),timestamp:1e3*t.l,statuses:t.p};g(null,a)}}))}function c(a,s,r,n,i){if("NewMessage"==i.delta.class){if(r.globalOptions.pageID&&r.globalOptions.pageID!=i.queue)return;!function t(a){if(a==i.delta.attachments?.length){let t;try{t=e.formatDeltaMessage(i)}catch(e){return n({error:"Problem parsing message object.",detail:e,res:i,type:"parse_error"})}return t&&r.globalOptions.autoMarkDelivery&&m(r,s,t.threadID,t.messageID),r.globalOptions.selfListen||t.senderID!==r.i_userID&&t.senderID!==r.userID?void n(null,t):void 0}if(Array.isArray(i.delta.attachments) && "photo"!=i.delta.attachments[a]?.mercury?.attach_type)return t(a+1);s.resolvePhotoUrl(i?.delta?.attachments[a]?.fbid,((e,s)=>(e||(i.delta.attachments[a].mercury.metadata.url=s),t(a+1))))}(0)}if("ClientPayload"==i.delta.class){const l=e.decodeClientPayload(i.delta.payload);if(l&&l.deltas){for(const i in l.deltas){var o=l.deltas[i];if(o.deltaMessageReaction&&r.globalOptions.listenEvents)n(null,{type:"message_reaction",threadID:(o.deltaMessageReaction.threadKey.threadFbId?o.deltaMessageReaction.threadKey.threadFbId:o.deltaMessageReaction.threadKey.otherUserFbId).toString(),messageID:o.deltaMessageReaction.messageId,reaction:o.deltaMessageReaction.reaction,senderID:0==o.deltaMessageReaction.senderId?o.deltaMessageReaction.userId.toString():o.deltaMessageReaction.senderId.toString(),userID:(o.deltaMessageReaction.userId||o.deltaMessageReaction.senderId).toString()});else if(o.deltaRecallMessageData&&r.globalOptions.listenEvents)n(null,{type:"message_unsend",threadID:(o.deltaRecallMessageData.threadKey.threadFbId?o.deltaRecallMessageData.threadKey.threadFbId:o.deltaRecallMessageData.threadKey.otherUserFbId).toString(),messageID:o.deltaRecallMessageData.messageID,senderID:o.deltaRecallMessageData.senderID.toString(),deletionTimestamp:o.deltaRecallMessageData.deletionTimestamp,timestamp:o.deltaRecallMessageData.timestamp});else if(o.deltaRemoveMessage&&r.globalOptions.listenEvents)n(null,{type:"message_self_delete",threadID:(o.deltaRemoveMessage.threadKey.threadFbId?o.deltaRemoveMessage.threadKey.threadFbId:o.deltaRemoveMessage.threadKey.otherUserFbId).toString(),messageID:1==o.deltaRemoveMessage.messageIds.length?o.deltaRemoveMessage.messageIds[0]:o.deltaRemoveMessage.messageIds,senderID:s.getCurrentUserID(),deletionTimestamp:o.deltaRemoveMessage.deletionTimestamp,timestamp:o.deltaRemoveMessage.timestamp});else if(o.deltaMessageReply){let i=void 0===o.deltaMessageReply.message||void 0===o.deltaMessageReply.message.data||void 0===o.deltaMessageReply.message.data.prng?[]:JSON.parse(o.deltaMessageReply.message.data.prng),l=i.map((e=>e.i)),d=i.map((e=>e.o)),g=i.map((e=>e.l));const c={};for(let e=0;e<l.length;e++)c[l[e]]=(o.deltaMessageReply.message.body||"").substring(d[e],d[e]+g[e]);const p={type:"message_reply",threadID:(o.deltaMessageReply.message.messageMetadata.threadKey.threadFbId?o.deltaMessageReply.message.messageMetadata.threadKey.threadFbId:o.deltaMessageReply.message.messageMetadata.threadKey.otherUserFbId).toString(),messageID:o.deltaMessageReply.message.messageMetadata.messageId,senderID:o.deltaMessageReply.message.messageMetadata.actorFbId.toString(),attachments:o.deltaMessageReply.message.attachments?.map((function(e){const t=JSON.parse(e.mercuryJSON);return Object.assign(e,t),e})).map((t=>{let a;try{a=e._formatAttachment(t)}catch(e){a=t,a.error=e,a.type="unknown"}return a})),body:o.deltaMessageReply.message.body||"",isGroup:!!o.deltaMessageReply.message.messageMetadata.threadKey.threadFbId,mentions:c,timestamp:o.deltaMessageReply.message.messageMetadata.timestamp,participantIDs:(o.deltaMessageReply.message.participants||[]).map((e=>e.toString()))};if(o.deltaMessageReply.repliedToMessage){i=void 0===o.deltaMessageReply.repliedToMessage||void 0===o.deltaMessageReply.repliedToMessage.data||void 0===o.deltaMessageReply.repliedToMessage.data.prng?[]:JSON.parse(o.deltaMessageReply.repliedToMessage.data.prng),l=i.map((e=>e.i)),d=i.map((e=>e.o)),g=i.map((e=>e.l));const t={};for(let e=0;e<l.length;e++)t[l[e]]=(o.deltaMessageReply.repliedToMessage.body||"").substring(d[e],d[e]+g[e]);p.messageReply={threadID:(o.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.threadFbId?o.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.threadFbId:o.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.otherUserFbId).toString(),messageID:o.deltaMessageReply.repliedToMessage.messageMetadata.messageId,senderID:o.deltaMessageReply.repliedToMessage.messageMetadata.actorFbId.toString(),attachments:o.deltaMessageReply.repliedToMessage.attachments.map((function(e){const t=JSON.parse(e.mercuryJSON);return Object.assign(e,t),e})).map((t=>{let a;try{a=e._formatAttachment(t)}catch(e){a=t,a.error=e,a.type="unknown"}return a})),body:o.deltaMessageReply.repliedToMessage.body||"",isGroup:!!o.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.threadFbId,mentions:t,timestamp:o.deltaMessageReply.repliedToMessage.messageMetadata.timestamp,participantIDs:(o.deltaMessageReply.repliedToMessage.participants||[]).map((e=>e.toString()))}}else{if(o.deltaMessageReply.replyToMessageId)return a.post("https://www.facebook.com/api/graphqlbatch/",r.jar,{av:r.globalOptions.pageID,queries:JSON.stringify({o0:{doc_id:"2848441488556444",query_params:{thread_and_message_id:{thread_id:p.threadID,message_id:o.deltaMessageReply.replyToMessageId.id}}}})}).then(e.parseAndCheckLogin(r,a)).then((t=>{if(t[t.length-1].error_results>0)throw t[0].o0.errors;if(0===t[t.length-1].successful_results)throw{error:"forcedFetch: there was no successful_results",res:t};const a=t[0].o0.data.message,s={};for(const e in a.message.ranges)s[a.message.ranges[e].entity.id]=(a.message.text||"").substr(a.message.ranges[e].offset,a.message.ranges[e].length);p.messageReply={threadID:p.threadID,messageID:a.message_id,senderID:a.message_sender.id.toString(),attachments:a.message.blob_attachment.map((t=>{let a;try{a=e._formatAttachment({blob_attachment:t})}catch(e){a=t,a.error=e,a.type="unknown"}return a})),body:a.message.text||"",isGroup:p.isGroup,mentions:s,timestamp:parseInt(a.timestamp_precise)}})).catch((e=>{t.error("forcedFetch",e)})).finally((function(){r.globalOptions.autoMarkDelivery&&m(r,s,p.threadID,p.messageID),(r.globalOptions.selfListen||p.senderID!==r.i_userID&&p.senderID!==r.userID)&&n(null,p)}));p.delta=o}return r.globalOptions.autoMarkDelivery&&m(r,s,p.threadID,p.messageID),r.globalOptions.selfListen||p.senderID!==r.i_userID&&p.senderID!==r.userID?void n(null,p):void 0}}return}}if("NewMessage"===i.delta.class||r.globalOptions.listenEvents)switch(i.delta.class){case"ReadReceipt":try{l=e.formatDeltaReadReceipt(i.delta)}catch(e){return n({error:"Problem parsing message object.",detail:e,res:i.delta,type:"parse_error"})}return void n(null,l);case"AdminTextMessage":switch(i.delta.type){case"change_thread_theme":case"change_thread_nickname":case"change_thread_icon":case"change_thread_admins":case"group_poll":var l;try{l=e.formatDeltaEvent(i.delta)}catch(e){return n({error:"Problem parsing message object.",detail:e,res:i.delta,type:"parse_error"})}return void n(null,l);default:return}case"ForcedFetch":if(!i.delta.threadKey)return;var d=i.delta.messageId,g=i.delta.threadKey.threadFbId;if(d&&g){const s={av:r.globalOptions.pageID,queries:JSON.stringify({o0:{doc_id:"2848441488556444",query_params:{thread_and_message_id:{thread_id:g.toString(),message_id:d}}}})};a.post("https://www.facebook.com/api/graphqlbatch/",r.jar,s).then(e.parseAndCheckLogin(r,a)).then((a=>{if(a[a.length-1].error_results>0)throw a[0].o0.errors;if(0===a[a.length-1].successful_results)throw{error:"forcedFetch: there was no successful_results",res:a};const s=a[0].o0.data.message;if("Object"==e.getType(s))switch(t.info("forcedFetch",s),s.__typename){case"ThreadImageMessage":(r.globalOptions.selfListenEvent||s.message_sender.id.toString()!==r.i_userID&&s.message_sender.id.toString()!==r.userID)&&r.loggedIn&&n(null,{type:"event",threadID:e.formatID(g.toString()),messageID:s.message_id,logMessageType:"log:thread-image",logMessageData:{attachmentID:s.image_with_metadata&&s.image_with_metadata.legacy_attachment_id,width:s.image_with_metadata&&s.image_with_metadata.original_dimensions.x,height:s.image_with_metadata&&s.image_with_metadata.original_dimensions.y,url:s.image_with_metadata&&s.image_with_metadata.preview.uri},logMessageBody:s.snippet,timestamp:s.timestamp_precise,author:s.message_sender.id});break;case"UserMessage":t.info("ff-Return",{type:"message",senderID:e.formatID(s.message_sender.id),body:s.message.text||"",threadID:e.formatID(g.toString()),messageID:s.message_id,attachments:[{type:"share",ID:s.extensible_attachment.legacy_attachment_id,url:s.extensible_attachment.story_attachment.url,title:s.extensible_attachment.story_attachment.title_with_entities.text,description:s.extensible_attachment.story_attachment.description.text,source:s.extensible_attachment.story_attachment.source,image:((s.extensible_attachment.story_attachment.media||{}).image||{}).uri,width:((s.extensible_attachment.story_attachment.media||{}).image||{}).width,height:((s.extensible_attachment.story_attachment.media||{}).image||{}).height,playable:(s.extensible_attachment.story_attachment.media||{}).is_playable||!1,duration:(s.extensible_attachment.story_attachment.media||{}).playable_duration_in_ms||0,subattachments:s.extensible_attachment.subattachments,properties:s.extensible_attachment.story_attachment.properties}],mentions:{},timestamp:parseInt(s.timestamp_precise),isGroup:s.message_sender.id!=g.toString()}),n(null,{type:"message",senderID:e.formatID(s.message_sender.id),body:s.message.text||"",threadID:e.formatID(g.toString()),messageID:s.message_id,attachments:[{type:"share",ID:s.extensible_attachment.legacy_attachment_id,url:s.extensible_attachment.story_attachment.url,title:s.extensible_attachment.story_attachment.title_with_entities.text,description:s.extensible_attachment.story_attachment.description.text,source:s.extensible_attachment.story_attachment.source,image:((s.extensible_attachment.story_attachment.media||{}).image||{}).uri,width:((s.extensible_attachment.story_attachment.media||{}).image||{}).width,height:((s.extensible_attachment.story_attachment.media||{}).image||{}).height,playable:(s.extensible_attachment.story_attachment.media||{}).is_playable||!1,duration:(s.extensible_attachment.story_attachment.media||{}).playable_duration_in_ms||0,subattachments:s.extensible_attachment.subattachments,properties:s.extensible_attachment.story_attachment.properties}],mentions:{},timestamp:parseInt(s.timestamp_precise),isGroup:s.message_sender.id!=g.toString()})}else t.error("forcedFetch",s)})).catch((e=>{t.error("forcedFetch",e)}))}break;case"ThreadName":case"ParticipantsAddedToGroupThread":case"ParticipantLeftGroupThread":case"ApprovalQueue":var c;try{c=e.formatDeltaEvent(i.delta)}catch(e){return n({error:"Problem parsing message object.",detail:e,res:i.delta,type:"parse_error"})}return(r.globalOptions.selfListenEvent||c.author.toString()!==r.i_userID&&c.author.toString()!==r.userID)&&r.loggedIn?void n(null,c):void 0}}function m(e,a,s,r){s&&r&&a.markAsDelivered(s,r,(r=>{r?t.error("markAsDelivered",r):e.globalOptions.autoMarkRead&&a.markAsRead(s,(e=>{e&&t.error("markAsDelivered",e)}))}))}module.exports=function(t,a,s){let r=i;return l=function(){return s.t_mqttCalled=!1,t.post("https://www.facebook.com/api/graphqlbatch/",s.jar,o).then(e.parseAndCheckLogin(s,t)).then((n=>{if("Array"!=e.getType(n)){const e=new Error("Not logged in");throw e.res=n,e.error="Not logged in",e}if(n&&n[n.length-1].error_results>0)throw n[0].o0.errors;if(0===n[n.length-1].successful_results)throw{error:"getSeqId: there was no successful_results",res:n};if(!n[0].o0.data.viewer.message_threads.sync_sequence_id){const e=new Error("No sync_sequence_id found.");throw e.res=n,e.error="getSeqId: no sync_sequence_id found.",e}s.lastSeqId=n[0].o0.data.viewer.message_threads.sync_sequence_id,g(t,a,s,r)})).catch((t=>{throw"Object"!=e.getType(t)||"Not logged in"!==t.error&&"Not logged in."!==t.error||(s.loggedIn=!1),t}))},function(e){const d=new class extends n{stopListening(e){e=e||(()=>{}),r=i,s.mqttClient&&(s.mqttClient.unsubscribe("/webrtc"),s.mqttClient.unsubscribe("/rtc_multi"),s.mqttClient.unsubscribe("/onevc"),s.mqttClient.publish("/browser_close","{}"),s.mqttClient.end(!1,(function(...t){e(t),s.mqttClient=void 0})))}async stopListeningSync(){return new Promise((e=>{this.stopListening(((...t)=>{e(t)}))}))}};return r=e||function(e,t){if(e)return d.emit("error",e);d.emit("message",t)},s.firstListen||(s.lastSeqId=null),s.syncToken=void 0,s.t_mqttCalled=!1,o={av:s.globalOptions.pageID,queries:JSON.stringify({o0:{doc_id:"3336396659757871",query_params:{limit:1,before:null,tags:["INBOX"],includeDeliveryReceipts:!1,includeSeqID:!0}}})},s.firstListen&&s.lastSeqId?g(t,a,s,r):l().catch((()=>{g(t,a,s,r)})),s.firstListen=!1,a.stopListening=d.stopListening,a.stopListeningSync=d.stopListeningSync,d}};
package/src/logout.js ADDED
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog");module.exports=function(o,n,r){return function(n){let u=function(){},s=function(){};const c=new Promise((function(e,t){u=e,s=t}));return n||(n=function(e,t){if(e)return s(e);u(t)}),o.post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",r.jar,{pmid:"0"}).then(e.parseAndCheckLogin(r,o)).then((function(t){const n=t.jsmods.instances[0][2][0].filter((function(e){return"logout"===e.value}))[0],u=t.jsmods.markup.filter((function(e){return e[0]===n.markup.__m}))[0][1].__html,s={fb_dtsg:e.getFrom(u,'"fb_dtsg" value="','"'),ref:e.getFrom(u,'"ref" value="','"'),h:e.getFrom(u,'"h" value="','"')};return o.post("https://www.facebook.com/logout.php",r.jar,s).then(e.saveCookies(r.jar))})).then((function(t){if(!t.headers)throw{error:"An error occurred when logging out."};return o.get(t.headers.location,r.jar).then(e.saveCookies(r.jar))})).then((function(){r.loggedIn=!1,t.info("logout","Logged out successfully."),n()})).catch((function(e){return t.error("logout",e),n(e)})),c}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),r=require("npmlog");module.exports=function(n,t,o){return function(t,i,s){let c=function(){},u=function(){};const a=new Promise((function(e,r){c=e,u=r}));if(s||(s=function(e,r){if(e)return u(e);c(r)}),!t||!i)return s("Error: messageID or threadID is not defined");const f={};return f["message_ids[0]"]=i,f["thread_ids["+t+"][0]"]=i,n.post("https://www.facebook.com/ajax/mercury/delivery_receipts.php",o.jar,f).then(e.saveCookies(o.jar)).then(e.parseAndCheckLogin(o,n)).then((function(e){if(e.error)throw e;return s()})).catch((function(n){return r.error("markAsDelivered",n),"Object"==e.getType(n)&&"Not logged in."===n.error&&(o.loggedIn=!1),s(n)})),a}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog");module.exports=function(r,n,a){return async function(n,o,s){"Function"!==e.getType(o)&&"AsyncFunction"!==e.getType(o)||(s=o,o=!0),null==o&&(o=!0),s||(s=()=>{});const i={};if(void 0!==a.globalOptions.pageID){let c;i.source="PagesManagerMessagesInterface",i.request_user_id=a.globalOptions.pageID,i["ids["+n+"]"]=o,i.watermarkTimestamp=(new Date).getTime(),i.shouldSendReadReceipt=!0,i.commerce_last_message_type="";try{c=await r.post("https://www.facebook.com/ajax/mercury/change_read_status.php",a.jar,i).then(e.saveCookies(a.jar)).then(e.parseAndCheckLogin(a,r))}catch(e){return s(e),e}if(c.error){const r=c.error;return t.error("markAsRead",r),"Object"==e.getType(r)&&"Not logged in."===r.error&&(a.loggedIn=!1),s(r),r}return s(),null}try{if(!a.mqttClient)throw{error:"You can only use this function after you start listening."};{const e=await new Promise((e=>a.mqttClient.publish("/mark_thread",JSON.stringify({threadID:n,mark:"read",state:o}),{qos:1,retain:!1},e)));if(e)throw e}}catch(e){return s(e),e}}};
@@ -0,0 +1 @@
1
+ const r=require("../utils"),n=require("npmlog");module.exports=function(e,o,t){return function(o){let u=function(){},i=function(){};const c=new Promise((function(r,n){u=r,i=n}));return o||(o=function(r,n){if(r)return i(r);u(n)}),e.post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",t.jar,{folder:"inbox"}).then(r.saveCookies(t.jar)).then(r.parseAndCheckLogin(t,e)).then((function(r){if(r.error)throw r;return o()})).catch((function(r){return n.error("markAsReadAll",r),o(r)})),c}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),n=require("npmlog");module.exports=function(t,r,o){return function(r,c){"Function"!=e.getType(r)&&"AsyncFunction"!=e.getType(r)||(c=r,r=Date.now());let i=function(){},u=function(){};const s=new Promise((function(e,n){i=e,u=n}));return c||(c=function(e,n){if(e)return u(e);i(n)}),t.post("https://www.facebook.com/ajax/mercury/mark_seen.php",o.jar,{seen_timestamp:r}).then(e.saveCookies(o.jar)).then(e.parseAndCheckLogin(o,t)).then((function(e){if(e.error)throw e;return c()})).catch((function(t){return n.error("markAsSeen",t),"Object"==e.getType(t)&&"Not logged in."===t.error&&(o.loggedIn=!1),c(t)})),s}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog");module.exports=function(n,r,o){return function(r,u,i){let c=function(){},a=function(){};const f=new Promise((function(e,t){c=e,a=t}));return i||(i=function(e,t){if(e)return a(e);c(t)}),n.post("https://www.facebook.com/ajax/mercury/change_mute_thread.php",o.jar,{thread_fbid:r,mute_settings:u}).then(e.saveCookies(o.jar)).then(e.parseAndCheckLogin(o,n)).then((function(e){if(e.error)throw e;return i()})).catch((function(e){return t.error("muteThread",e),i(e)})),f}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),r=require("npmlog");module.exports=function(t,o,n){return function(o,i,u){if(!u&&("Function"===e.getType(i)||"AsyncFunction"===e.getType(i)))throw{error:"please pass a threadID as a second argument."};if("Number"!==e.getType(i)&&"String"!==e.getType(i))throw{error:"threadID should be of type Number or String and not "+e.getType(i)+"."};if("Number"!==e.getType(o)&&"String"!==e.getType(o))throw{error:"userID should be of type Number or String and not "+e.getType(o)+"."};let c=function(){},p=function(){};const f=new Promise((function(e,r){c=e,p=r}));return u||(u=function(e,r){if(e)return p(e);c(r)}),t.post("https://www.facebook.com/chat/remove_participants",n.jar,{uid:o,tid:i}).then(e.parseAndCheckLogin(n,t)).then((function(e){if(!e)throw{error:"Remove from group failed."};if(e.error)throw e;return u()})).catch((function(e){return r.error("removeUserFromGroup",e),u(e)})),f}};
@@ -0,0 +1 @@
1
+ const r=require("../utils"),t=require("npmlog");module.exports=function(e,o,n){return function(o,u){let c=function(){},i=function(){};const s=new Promise((function(r,t){c=r,i=t}));return u||(u=function(r,t){if(r)return i(r);c(t)}),e.get("https://www.facebook.com/mercury/attachments/photo",n.jar,{photo_id:o}).then(r.parseAndCheckLogin(n,e)).then((r=>{if(r.error)throw r;return u(null,r.jsmods.require[0][3][0])})).catch((r=>(t.error("resolvePhotoUrl",r),u(r)))),s}};
@@ -0,0 +1 @@
1
+ const r=require("../utils");module.exports=function(e,n,t){return function(n,o){let a=function(){},u=function(){};const i=new Promise((function(r,e){a=r,u=e}));return o||(o=function(r,e){if(r)return u(r);a(e)}),e.post("https://www.facebook.com/ajax/mercury/search_threads.php",t.jar,{client:"web_messenger",query:n,offset:0,limit:21,index:"fbid"}).then(r.parseAndCheckLogin(t,e)).then((function(e){if(e.error)throw e;return e.payload.mercury_payload.threads?o(null,e.payload.mercury_payload.threads.map(r.formatThread)):o({error:"Could not find thread `"+n+"`."})})),i}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog"),r=require("bluebird"),n={attachment:!0,url:!0,sticker:!0,emoji:!0,emojiSize:!0,body:!0,mentions:!0,location:!0};module.exports=function(i,o,a){function s(r,n,o,s,l){if("Array"===e.getType(n)){for(let e=0;e<n.length;e++)r["specific_to_list["+e+"]"]="fbid:"+n[e];r["specific_to_list["+n.length+"]"]="fbid:"+(a.i_userID||a.userID),r.client_thread_id="root:"+s,t.info("sendMessage","Sending message to multiple users: "+n)}else o?(r["specific_to_list[0]"]="fbid:"+n,r["specific_to_list[1]"]="fbid:"+(a.i_userID||a.userID),r.other_user_fbid=n):r.thread_fbid=n;a.globalOptions.pageID&&(r.author="fbid:"+a.globalOptions.pageID,r["specific_to_list[1]"]="fbid:"+a.globalOptions.pageID,r["creator_info[creatorID]"]=a.i_userID||a.userID,r["creator_info[creatorType]"]="direct_admin",r["creator_info[labelType]"]="sent_message",r["creator_info[pageID]"]=a.globalOptions.pageID,r.request_user_id=a.globalOptions.pageID,r["creator_info[profileURI]"]="https://www.facebook.com/profile.php?id="+(a.i_userID||a.userID)),i.post("https://www.facebook.com/messaging/send/",a.jar,r).then(e.parseAndCheckLogin(a,i)).then((function(e){if(!e)return l({error:"Send message failed."});if(e.error)return 1545012===e.error&&t.warn("sendMessage","Got error 1545012. This might mean that you're not part of the conversation "+n),l(e);const r=e.payload.actions.reduce((function(e,t){return{threadID:t.thread_fbid,messageID:t.message_id,timestamp:t.timestamp}||e}),null);return l(null,r)})).catch((function(r){return t.error("sendMessage",r),"Object"==e.getType(r)&&"Not logged in."===r.error&&(a.loggedIn=!1),l(r)}))}return function(o,l,c,u,d){if(void 0===d&&(d=null),!c&&("Function"===e.getType(l)||"AsyncFunction"===e.getType(l)))return l({error:"Pass a threadID as a second argument."});u||"String"!==e.getType(c)||(u=c,c=function(){});let f=function(){},m=function(){};const p=new Promise((function(e,t){f=e,m=t}));c||(c=function(e,t){if(e)return m(e);f(t)});const _=e.getType(o),g=e.getType(l),h=e.getType(u);if("String"!==_&&"Object"!==_)return c({error:"Message should be of type string or object and not "+_+"."});if("Array"!==g&&"Number"!==g&&"String"!==g)return c({error:"ThreadID should be of type number, string, or array and not "+g+"."});if(u&&"String"!==h)return c({error:"MessageID should be of type string and not "+g+"."});"String"===_&&(o={body:o});const y=Object.keys(o).filter((e=>!n[e]));if(y.length>0)return c({error:"Dissallowed props: `"+y.join(", ")+"`"});const b=e.generateOfflineThreadingID(),I={client:"mercury",action_type:"ma-type:user-generated-message",author:"fbid:"+(a.i_userID||a.userID),timestamp:Date.now(),timestamp_absolute:"Today",timestamp_relative:e.generateTimestampRelative(),timestamp_time_passed:"0",is_unread:!1,is_cleared:!1,is_forward:!1,is_filtered_content:!1,is_filtered_content_bh:!1,is_filtered_content_account:!1,is_filtered_content_quasar:!1,is_filtered_content_invalid_app:!1,is_spoof_warning:!1,source:"source:chat:web","source_tags[0]":"source:chat",body:o.body?o.body.toString():"",html_body:!1,ui_push_phase:"V3",status:"0",offline_threading_id:b,message_id:b,threading_id:e.generateThreadingID(a.clientID),"ephemeral_ttl_mode:":"0",manual_retry_cnt:"0",has_attachment:!!(o.attachment||o.url||o.sticker),signatureID:e.getSignatureID(),replied_to_message_id:u};return function(n,u,f,m){if(n.location){if(null==n.location.latitude||null==n.location.longitude)return f({error:"location property needs both latitude and longitude"});u["location_attachment[coordinates][latitude]"]=n.location.latitude,u["location_attachment[coordinates][longitude]"]=n.location.longitude,u["location_attachment[is_current_location]"]=!!n.location.current}!function(n,u,f,m){n.sticker&&(u.sticker_id=n.sticker),function(n,o,s,l){n.attachment?(o.image_ids=[],o.gif_ids=[],o.file_ids=[],o.video_ids=[],o.audio_ids=[],"Array"!==e.getType(n.attachment)&&(n.attachment=[n.attachment]),function(n,o){const s=[];for(let t=0;t<n.length;t++){if(!e.isReadableStream(n[t]))throw{error:"Attachment should be a readable stream and not "+e.getType(n[t])+"."};s.push(i.postFormData("https://upload.facebook.com/ajax/mercury/upload.php",a.jar,{upload_1024:n[t],voice_clip:"true"},{}).then(e.parseAndCheckLogin(a,i)).then((function(e){if(e.error)throw e;return e.payload.metadata[0]})))}r.all(s).then((function(e){o(null,e)})).catch((function(e){return t.error("uploadAttachment",e),o(e)}))}(n.attachment,(function(e,t){if(e)return s(e);t.forEach((function(e){const t=Object.keys(e)[0];o[t+"s"].push(e[t])})),l()}))):l()}(o,I,c,(()=>function(r,n,o,s){var l;r.url?(n["shareable_attachment[share_type]"]="100",l=function(e,t){if(e)return o(e);n["shareable_attachment[share_params]"]=t,s()},i.post("https://www.facebook.com/message_share_attachment/fromURI/",a.jar,{image_height:960,image_width:960,uri:r.url}).then(e.parseAndCheckLogin(a,i)).then((function(e){return e.error?l(e):e.payload?void l(null,e.payload.share_data.share_params):l({error:"Invalid url"})})).catch((function(e){return t.error("getUrl",e),l(e)}))):s()}(o,I,c,(()=>function(r,n,i,a){if(null!=r.emojiSize&&null==r.emoji)return i({error:"emoji property is empty"});if(r.emoji){if(null==r.emojiSize&&(r.emojiSize="medium"),"small"!=r.emojiSize&&"medium"!=r.emojiSize&&"large"!=r.emojiSize)return i({error:"emojiSize property is invalid"});if(null!=n.body&&""!=n.body)return i({error:"body is not empty"});n.body=r.emoji,n["tags[0]"]="hot_emoji_size:"+r.emojiSize}!function(r,n,i,o){if(r.mentions)for(let e=0;e<r.mentions.length;e++){const o=r.mentions[e],a=o.tag;if("string"!=typeof a)return i({error:"Mention tags must be strings."});const s=r.body.indexOf(a,o.fromIndex||0);s<0&&t.warn("handleMention",'Mention for "'+a+'" not found in message string.'),null==o.id&&t.warn("handleMention","Mention id should be non-null.");const l=o.id||0;n["profile_xmd["+e+"][offset]"]=s,n["profile_xmd["+e+"][length]"]=a.length,n["profile_xmd["+e+"][id]"]=l,n["profile_xmd["+e+"][type]"]="p"}!function(t,r,n,i,o){"Array"===e.getType(r)?s(t,r,!1,n,i):"Boolean"!=e.getType(o)?s(t,r,r.toString().length<16,n,i):s(t,r,!o,n,i)}(I,l,b,c,d)}(o,I,c)}(o,I,c)))))}(o,I)}(o,I,c),p}};
@@ -0,0 +1 @@
1
+ const n=require("../utils"),t=require("npmlog");module.exports=function(e,o,r){function c(c,i,g,a){const u={typ:+c,to:"",source:"mercury-chat",thread:i};"Boolean"==n.getType(a)?(a||(u.to=i),e.post("https://www.facebook.com/ajax/messaging/typ.php",r.jar,u).then(n.parseAndCheckLogin(r,e)).then((function(n){if(n.error)throw n;return g()})).catch((function(e){return t.error("sendTypingIndicator",e),"Object"==n.getType(e)&&"Not logged in"===e.error&&(r.loggedIn=!1),g(e)}))):o.getUserInfo(i,(function(o,c){if(o)return g(o);Object.keys(c).length>0&&(u.to=i),e.post("https://www.facebook.com/ajax/messaging/typ.php",r.jar,u).then(n.parseAndCheckLogin(r,e)).then((function(n){if(n.error)throw n;return g()})).catch((function(e){return t.error("sendTypingIndicator",e),"Object"==n.getType(e)&&"Not logged in."===e.error&&(r.loggedIn=!1),g(e)}))}))}return function(e,o,r){return"Function"!==n.getType(o)&&"AsyncFunction"!==n.getType(o)&&(o&&t.warn("sendTypingIndicator","callback is not a function - ignoring."),o=()=>{}),c(!0,e,o,r),function(o){"Function"!==n.getType(o)&&"AsyncFunction"!==n.getType(o)&&(o&&t.warn("sendTypingIndicator","callback is not a function - ignoring."),o=()=>{}),c(!1,e,o,r)}}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),a=require("npmlog");module.exports=function(r,t,c){return function(t,n,s,o){let i=function(){},u=function(){};const h=new Promise((function(e,a){i=e,u=a}));switch(s||(s=function(e,a){if(e)return u(e);i(a)}),t){case"😍":case"😆":case"😮":case"😢":case"😠":case"👍":case"👎":case"❤":case"💗":case"":break;case":heart_eyes:":case":love:":t="😍";break;case":laughing:":case":haha:":t="😆";break;case":open_mouth:":case":wow:":t="😮";break;case":cry:":case":sad:":t="😢";break;case":angry:":t="😠";break;case":thumbsup:":case":like:":t="👍";break;case":thumbsdown:":case":dislike:":t="👎";break;case":heart:":t="❤";break;case":glowingheart:":t="💗";break;default:if(o)break;return s({error:"Reaction is not a valid emoji."})}const b={data:{client_mutation_id:c.clientMutationId++,actor_id:c.i_userID||c.userID,action:""==t?"REMOVE_REACTION":"ADD_REACTION",message_id:n,reaction:t}},l={doc_id:"1491398900900362",variables:JSON.stringify(b),dpr:1};return r.postFormData("https://www.facebook.com/webgraphql/mutation/",c.jar,{},l).then(e.parseAndCheckLogin(c.jar,r)).then((function(e){if(!e)throw{error:"setReaction returned empty object."};if(e.error)throw e;s(null)})).catch((function(e){return a.error("setReaction",e),s(e)})),h}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog");module.exports=function(r,n,a){return function(n,o,c){let i=function(){},d=function(){};const s=new Promise((function(e,t){i=e,d=t}));if(c||("Function"===e.getType(o)||"AsyncFunction"===e.getType(o)?(c=o,o=0):c=function(e,t){if(e)return d(e);i(t)}),"Number"!==e.getType(o)&&"String"===e.getType(o)&&(o={unlike:0,like:1,heart:2,love:16,haha:4,wow:3,sad:7,angry:8}[o.toLowerCase()]),"Number"!==e.getType(o)&&"String"!==e.getType(o))throw{error:"setPostReaction: Invalid reaction type"};if(0!=o&&!o)throw{error:"setPostReaction: Invalid reaction type"};const u={av:a.userID,fb_api_caller_class:"RelayModern",fb_api_req_friendly_name:"CometUFIFeedbackReactMutation",doc_id:"4769042373179384",variables:JSON.stringify({input:{actor_id:a.i_userID||a.userID,feedback_id:new Buffer("feedback:"+n).toString("base64"),feedback_reaction:o,feedback_source:"OBJECT",is_tracking_encrypted:!0,tracking:[],session_id:"f7dd50dd-db6e-4598-8cd9-561d5002b423",client_mutation_id:Math.round(19*Math.random()).toString()},useDefaultActor:!1,scale:3})};return r.post("https://www.facebook.com/api/graphql/",a.jar,u).then(e.parseAndCheckLogin(a,r)).then((function(e){if(e.errors)throw e;return c(null,{viewer_feedback_reaction_info:(t=e.data).feedback_react.feedback.viewer_feedback_reaction_info,supported_reactions:t.feedback_react.feedback.supported_reactions,top_reactions:t.feedback_react.feedback.top_reactions.edges,reaction_count:t.feedback_react.feedback.reaction_count});var t})).catch((function(e){return t.error("setPostReaction",e),c(e)})),s}};
@@ -0,0 +1 @@
1
+ const e=require("../utils"),t=require("npmlog");module.exports=function(r,n,a){return function(n,o,i){if(!i&&("Function"===e.getType(o)||"AsyncFunction"===e.getType(o)))throw{error:"please pass a threadID as a second argument."};let s=function(){},c=function(){};const u=new Promise((function(e,t){s=e,c=t}));i||(i=function(e,t){if(e)return c(e);s(t)});const m=e.generateOfflineThreadingID(),_={client:"mercury",action_type:"ma-type:log-message",author:"fbid:"+(a.i_userID||a.userID),author_email:"",coordinates:"",timestamp:Date.now(),timestamp_absolute:"Today",timestamp_relative:e.generateTimestampRelative(),timestamp_time_passed:"0",is_unread:!1,is_cleared:!1,is_forward:!1,is_filtered_content:!1,is_spoof_warning:!1,source:"source:chat:web","source_tags[0]":"source:chat",status:"0",offline_threading_id:m,message_id:m,threading_id:e.generateThreadingID(a.clientID),manual_retry_cnt:"0",thread_fbid:o,thread_name:n,thread_id:o,log_message_type:"log:thread-name"};return r.post("https://www.facebook.com/messaging/set_thread_name/",a.jar,_).then(e.parseAndCheckLogin(a,r)).then((function(e){if(e.error&&1545012===e.error)throw{error:"Cannot change chat title: Not member of chat."};if(e.error&&1545003===e.error)throw{error:"Cannot set title of single-user chat."};if(e.error)throw e;return i()})).catch((function(e){return t.error("setTitle",e),i(e)})),u}};
@@ -0,0 +1 @@
1
+ module.exports=function(e,r,a){return{MessengerBlue:"196241301102133",Viking:"1928399724138152",GoldenPoppy:"174636906462322",RadicalRed:"2129984390566328",Shocking:"2058653964378557",FreeSpeechGreen:"2136751179887052",Pumpkin:"175615189761153",LightCoral:"980963458735625",MediumSlateBlue:"234137870477637",DeepSkyBlue:"2442142322678320",BrilliantRose:"169463077092846",DefaultBlue:"196241301102133",HotPink:"169463077092846",AquaBlue:"2442142322678320",BrightPurple:"234137870477637",CoralPink:"980963458735625",Orange:"175615189761153",Green:"2136751179887052",LavenderPurple:"2058653964378557",Red:"2129984390566328",Yellow:"174636906462322",TealBlue:"1928399724138152",Aqua:"417639218648241",Mango:"930060997172551",Berry:"164535220883264",Citrus:"370940413392601",Candy:"205488546921017",Earth:"1833559466821043",Support:"365557122117011",Music:"339021464972092",Pride:"1652456634878319",DoctorStrange:"538280997628317",LoFi:"1060619084701625",Sky:"3190514984517598",LunarNewYear:"357833546030778",Celebration:"627144732056021",Chill:"390127158985345",StrangerThings:"1059859811490132",Dune:"1455149831518874",Care:"275041734441112",Astrology:"3082966625307060",JBalvin:"184305226956268",Birthday:"621630955405500",Cottagecore:"539927563794799",Ocean:"736591620215564",Love:"741311439775765",TieDye:"230032715012014",Monochrome:"788274591712841",Default:"3259963564026002",Rocket:"582065306070020",Berry2:"724096885023603",Candy2:"624266884847972",Unicorn:"273728810607574",Tropical:"262191918210707",Maple:"2533652183614000",Sushi:"909695489504566",Citrus2:"557344741607350",Lollipop:"280333826736184",Shadow:"271607034185782",Rose:"1257453361255152",Lavender:"571193503540759",Tulip:"2873642949430623",Classic:"3273938616164733",Peach:"3022526817824329",Honey:"672058580051520",Kiwi:"3151463484918004",Grape:"193497045377796",NonBinary:"737761000603635",ThankfulForFriends:"1318983195536293",Transgender:"504518465021637",TaylorSwift:"769129927636836",NationalComingOutDay:"788102625833584",Autumn:"822549609168155",Cyberpunk2077:"780962576430091"}};
@@ -0,0 +1 @@
1
+ const n=require("../utils"),e=require("npmlog");module.exports=function(r,t,o){return function(t,i){let u=function(){},c=function(){};const f=new Promise((function(n,e){u=n,c=e}));return i||(i=function(n,e){if(n)return c(n);u(e)}),r.post("https://www.facebook.com/ajax/profile/removefriendconfirm.php",o.jar,{uid:t,unref:"bd_friends_tab",floc:"friends_tab","nctr[_mod]":"pagelet_timeline_app_collection_"+(o.i_userID||o.userID)+":2356318349:2"}).then(n.parseAndCheckLogin(o,r)).then((function(n){if(n.error)throw n;return i()})).catch((function(n){return e.error("unfriend",n),i(n)})),f}};
@@ -0,0 +1 @@
1
+ const n=require("../utils"),e=require("npmlog");module.exports=function(r,t,o){return function(t,u){let s=function(){},i=function(){};const c=new Promise((function(n,e){s=n,i=e}));return u||(u=function(n,e){if(n)return i(n);s(e)}),r.post("https://www.facebook.com/messaging/unsend_message/",o.jar,{message_id:t}).then(n.parseAndCheckLogin(o,r)).then((function(n){if(n.error)throw n;return u()})).catch((function(n){return e.error("unsendMessage",n),u(n)})),c}};
@@ -0,0 +1 @@
1
+ const t=require("../utils"),e=require("npmlog"),r=require("bluebird");module.exports=function(n,a,o){return function(a,u){if(!a&&!t.isReadableStream(a)&&"Array"===!t.getType(a)&&"Array"===t.getType(a)&&!a.length)throw{error:"Please pass an attachment or an array of attachments."};let i=function(){},c=function(){};const l=new Promise((function(t,e){i=t,c=e}));return u||(u=function(t,e){if(t)return c(t);i(e)}),"Array"!==t.getType(a)&&(a=[a]),function(a,u){u=u||function(){};const i=[];for(let e=0;e<a.length;e++){if(!t.isReadableStream(a[e]))throw{error:"Attachment should be a readable stream and not "+t.getType(a[e])+"."};i.push(n.postFormData("https://upload.facebook.com/ajax/mercury/upload.php",o.jar,{upload_1024:a[e],voice_clip:"true"},{}).then(t.parseAndCheckLogin(o,n)).then((function(t){if(t.error)throw t;return t.payload.metadata[0]})))}r.all(i).then((function(t){u(null,t)})).catch((function(t){return e.error("uploadAttachment",t),u(t)}))}(a,((t,e)=>{if(t)return u(t);u(null,e)})),l}};
package/utils.js ADDED
@@ -0,0 +1 @@
1
+ const e=require("bluebird");let t=e.promisify(require("request").defaults({jar:!0,proxy:process.env.FB_PROXY}));const a=require("stream"),r=require("npmlog"),i=require("querystring"),n=require("url");function s(e,t,a,r){const i={"Content-Type":"application/x-www-form-urlencoded",Referer:"https://www.facebook.com/",Host:e.replace("https://","").split("/")[0],Origin:"https://www.facebook.com","User-Agent":t.userAgent,Connection:"keep-alive","sec-fetch-site":"same-origin"};return r&&Object.assign(i,r),a&&a.region&&(i["X-MSGR-Region"]=a.region),i}function o(e,a,r,i,n){if("Object"===I(r))for(const e in r)r.hasOwnProperty(e)&&"Object"===I(r[e])&&(r[e]=JSON.stringify(r[e]));const o={headers:s(e,i,n),timeout:6e4,qs:r,url:e,method:"GET",jar:a,gzip:!0};return t(o).then((function(e){return Array.isArray(e)?e[0]:e}))}function m(e,a,r,i,n,o){const m={headers:s(e,i,n,o),timeout:6e4,url:e,method:"POST",form:r,jar:a,gzip:!0};return t(m).then((function(e){return Array.isArray(e)?e[0]:e}))}function c(e,a,r,i,n,o){const m=s(e,n,o);return m["Content-Type"]="multipart/form-data",t({headers:m,timeout:6e4,url:e,method:"POST",formData:r,qs:i,jar:a,gzip:!0}).then((function(e){return Array.isArray(e)?e[0]:e}))}let l;const d={},u={_:"%",A:"%2",B:"000",C:"%7d",D:"%7b%22",E:"%2c%22",F:"%22%3a",G:"%2c%22ut%22%3a1",H:"%2c%22bls%22%3a",I:"%2c%22n%22%3a%22%",J:"%22%3a%7b%22i%22%3a0%7d",K:"%2c%22pt%22%3a0%2c%22vis%22%3a",L:"%2c%22ch%22%3a%7b%22h%22%3a%22",M:"%7b%22v%22%3a2%2c%22time%22%3a1",N:".channel%22%2c%22sub%22%3a%5b",O:"%2c%22sb%22%3a1%2c%22t%22%3a%5b",P:"%2c%22ud%22%3a100%2c%22lc%22%3a0",Q:"%5d%2c%22f%22%3anull%2c%22uct%22%3a",R:".channel%22%2c%22sub%22%3a%5b1%5d",S:"%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",T:"%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",U:"%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",V:"%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",W:"%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",X:"%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",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",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"};function p(e,t=""){if(e)return e;{const e=t.split(".").pop();return e===t?"":e}}function g(e,t){const a=e.filename,r=Number(e.fileSize||0),s=e.genericMetadata?Number(e.genericMetadata.videoLength):void 0,o=e.genericMetadata?Number(e.genericMetadata.duration):void 0,m=e.mimeType;t=t||{id:"",image_data:{}};let c=(e=e.mercury||e).blob_attachment||e.sticker_attachment,l=c&&c.__typename?c.__typename:e.attach_type;switch(!l&&e.sticker_attachment?(l="StickerAttachment",c=e.sticker_attachment):!l&&e.extensible_attachment&&(l=e.extensible_attachment.story_attachment&&e.extensible_attachment.story_attachment.target&&e.extensible_attachment.story_attachment.target.__typename&&"MessageLocation"===e.extensible_attachment.story_attachment.target.__typename?"MessageLocation":"ExtensibleAttachment",c=e.extensible_attachment),l){case"sticker":return{type:"sticker",ID:e.metadata.stickerID.toString(),url:e.url,packID:e.metadata.packID.toString(),spriteUrl:e.metadata.spriteURI,spriteUrl2x:e.metadata.spriteURI2x,width:e.metadata.width,height:e.metadata.height,caption:t.caption,description:t.description,frameCount:e.metadata.frameCount,frameRate:e.metadata.frameRate,framesPerRow:e.metadata.framesPerRow,framesPerCol:e.metadata.framesPerCol,stickerID:e.metadata.stickerID.toString(),spriteURI:e.metadata.spriteURI,spriteURI2x:e.metadata.spriteURI2x};case"file":return{type:"file",ID:t.id.toString(),fullFileName:a,filename:e.name,fileSize:r,original_extension:p(e.original_extension,a),mimeType:m,url:e.url,isMalicious:t.is_malicious,contentType:t.mime_type,name:e.name};case"photo":return{type:"photo",ID:e.metadata.fbid.toString(),filename:e.fileName,fullFileName:a,fileSize:r,original_extension:p(e.original_extension,a),mimeType:m,thumbnailUrl:e.thumbnail_url,previewUrl:e.preview_url,previewWidth:e.preview_width,previewHeight:e.preview_height,largePreviewUrl:e.large_preview_url,largePreviewWidth:e.large_preview_width,largePreviewHeight:e.large_preview_height,url:e.metadata.url,width:e.metadata.dimensions.split(",")[0],height:e.metadata.dimensions.split(",")[1],name:a};case"animated_image":return{type:"animated_image",ID:t.id.toString(),filename:t.filename,fullFileName:a,original_extension:p(t.original_extension,a),mimeType:m,previewUrl:e.preview_url,previewWidth:e.preview_width,previewHeight:e.preview_height,url:t.image_data.url,width:t.image_data.width,height:t.image_data.height,name:e.name,facebookUrl:e.url,thumbnailUrl:e.thumbnail_url,rawGifImage:t.image_data.raw_gif_image,rawWebpImage:t.image_data.raw_webp_image,animatedGifUrl:t.image_data.animated_gif_url,animatedGifPreviewUrl:t.image_data.animated_gif_preview_url,animatedWebpUrl:t.image_data.animated_webp_url,animatedWebpPreviewUrl:t.image_data.animated_webp_preview_url};case"share":return{type:"share",ID:e.share.share_id.toString(),url:t.href,title:e.share.title,description:e.share.description,source:e.share.source,image:e.share.media.image,width:e.share.media.image_size.width,height:e.share.media.image_size.height,playable:e.share.media.playable,duration:e.share.media.duration,subattachments:e.share.subattachments,properties:{},animatedImageSize:e.share.media.animated_image_size,facebookUrl:e.share.uri,target:e.share.target,styleList:e.share.style_list};case"video":return{type:"video",ID:e.metadata.fbid.toString(),filename:e.name,fullFileName:a,original_extension:p(e.original_extension,a),mimeType:m,duration:s,previewUrl:e.preview_url,previewWidth:e.preview_width,previewHeight:e.preview_height,url:e.url,width:e.metadata.dimensions.width,height:e.metadata.dimensions.height,videoType:"unknown",thumbnailUrl:e.thumbnail_url};case"error":return{type:"error",attachment1:e,attachment2:t};case"MessageImage":return{type:"photo",ID:c.legacy_attachment_id,filename:c.filename,fullFileName:a,fileSize:r,original_extension:p(c.original_extension,a),mimeType:m,thumbnailUrl:c.thumbnail.uri,previewUrl:c.preview.uri,previewWidth:c.preview.width,previewHeight:c.preview.height,largePreviewUrl:c.large_preview.uri,largePreviewWidth:c.large_preview.width,largePreviewHeight:c.large_preview.height,url:c.large_preview.uri,width:c.original_dimensions.x,height:c.original_dimensions.y,name:c.filename};case"MessageAnimatedImage":return{type:"animated_image",ID:c.legacy_attachment_id,filename:c.filename,fullFileName:a,original_extension:p(c.original_extension,a),mimeType:m,previewUrl:c.preview_image.uri,previewWidth:c.preview_image.width,previewHeight:c.preview_image.height,url:c.animated_image.uri,width:c.animated_image.width,height:c.animated_image.height,thumbnailUrl:c.preview_image.uri,name:c.filename,facebookUrl:c.animated_image.uri,rawGifImage:c.animated_image.uri,animatedGifUrl:c.animated_image.uri,animatedGifPreviewUrl:c.preview_image.uri,animatedWebpUrl:c.animated_image.uri,animatedWebpPreviewUrl:c.preview_image.uri};case"MessageVideo":return{type:"video",ID:c.legacy_attachment_id,filename:c.filename,fullFileName:a,original_extension:p(c.original_extension,a),fileSize:r,duration:s,mimeType:m,previewUrl:c.large_image.uri,previewWidth:c.large_image.width,previewHeight:c.large_image.height,url:c.playable_url,width:c.original_dimensions.x,height:c.original_dimensions.y,videoType:c.video_type.toLowerCase(),thumbnailUrl:c.large_image.uri};case"MessageAudio":return{type:"audio",ID:c.url_shimhash,filename:c.filename,fullFileName:a,fileSize:r,duration:o,original_extension:p(c.original_extension,a),mimeType:m,audioType:c.audio_type,url:c.playable_url,isVoiceMail:c.is_voicemail};case"StickerAttachment":case"Sticker":return{type:"sticker",ID:c.id,url:c.url,packID:c.pack?c.pack.id:null,spriteUrl:c.sprite_image,spriteUrl2x:c.sprite_image_2x,width:c.width,height:c.height,caption:c.label,description:c.label,frameCount:c.frame_count,frameRate:c.frame_rate,framesPerRow:c.frames_per_row,framesPerCol:c.frames_per_column,stickerID:c.id,spriteURI:c.sprite_image,spriteURI2x:c.sprite_image_2x};case"MessageLocation":var d,u,g,h,_,f=c.story_attachment.url,y=c.story_attachment.media,b=i.parse(n.parse(f).query).u,w=i.parse(n.parse(b).query).where1,v=w.split(", ");try{d=Number.parseFloat(v[0]),u=Number.parseFloat(v[1])}catch(e){}return y&&y.image&&(g=y.image.uri,h=y.image.width,_=y.image.height),{type:"location",ID:c.legacy_attachment_id,latitude:d,longitude:u,image:g,width:h,height:_,url:b||f,address:w,facebookUrl:c.story_attachment.url,target:c.story_attachment.target,styleList:c.story_attachment.style_list};case"ExtensibleAttachment":return{type:"share",ID:c.legacy_attachment_id,url:c.story_attachment.url,title:c.story_attachment.title_with_entities.text,description:c.story_attachment.description&&c.story_attachment.description.text,source:c.story_attachment.source?c.story_attachment.source.text:null,image:c.story_attachment.media&&c.story_attachment.media.image&&c.story_attachment.media.image.uri,width:c.story_attachment.media&&c.story_attachment.media.image&&c.story_attachment.media.image.width,height:c.story_attachment.media&&c.story_attachment.media.image&&c.story_attachment.media.image.height,playable:c.story_attachment.media&&c.story_attachment.media.is_playable,duration:c.story_attachment.media&&c.story_attachment.media.playable_duration_in_ms,playableUrl:null==c.story_attachment.media?null:c.story_attachment.media.playable_url,subattachments:c.story_attachment.subattachments,properties:c.story_attachment.properties.reduce((function(e,t){return e[t.key]=t.value.text,e}),{}),facebookUrl:c.story_attachment.url,target:c.story_attachment.target,styleList:c.story_attachment.style_list};case"MessageFile":return{type:"file",ID:c.message_file_fbid,fullFileName:a,filename:c.filename,fileSize:r,mimeType:c.mimetype,original_extension:c.original_extension||a.split(".").pop(),url:c.url,isMalicious:c.is_malicious,contentType:c.content_type,name:c.filename};default:throw new Error("unrecognized attach_file of type "+l+"`"+JSON.stringify(e,null,4)+" attachment2: "+JSON.stringify(t,null,4)+"`")}}function h(e){return null!=e&&null!=e?e.replace(/(fb)?id[:.]/,""):e}function _(e){const t=e.message?e.message:e,a={type:"message",senderName:t.sender_name,senderID:h(t.sender_fbid.toString()),participantNames:t.group_thread_info?t.group_thread_info.participant_names:[t.sender_name.split(" ")[0]],participantIDs:t.group_thread_info?t.group_thread_info.participant_ids.map((function(e){return h(e.toString())})):[h(t.sender_fbid)],body:t.body||"",threadID:h((t.thread_fbid||t.other_user_fbid).toString()),threadName:t.group_thread_info?t.group_thread_info.name:t.sender_name,location:t.coordinates?t.coordinates:null,messageID:t.mid?t.mid.toString():t.message_id,attachments:(r=t.attachments,i=t.attachmentIds,n=t.attachment_map,s=t.share_map,n=s||n,r?r.map((function(e,t){return n&&i&&n[i[t]]?g(e,n[i[t]]):g(e)})):[]),timestamp:t.timestamp,timestampAbsolute:t.timestamp_absolute,timestampRelative:t.timestamp_relative,timestampDatetime:t.timestamp_datetime,tags:t.tags,reactions:t.reactions?t.reactions:[],isUnread:t.is_unread};var r,i,n,s;return"pages_messaging"===e.type&&(a.pageID=e.realtime_viewer_fbid.toString()),a.isGroup=a.participantIDs.length>2,a}function f(e){switch(e){case"change_thread_theme":return"log:thread-color";case"change_thread_icon":return"log:thread-icon";case"change_thread_nickname":return"log:user-nickname";case"change_thread_admins":return"log:thread-admins";case"group_poll":return"log:thread-poll";case"change_thread_approval_mode":return"log:thread-approval-mode";case"messenger_call_log":case"participant_joined_group_call":return"log:thread-call";default:return e}}function y(e,t,a){const r=e.indexOf(t)+t.length;if(r<t.length)return"";const i=e.substring(r),n=i.indexOf(a);if(-1===n)throw Error("Could not find endTime `"+a+"` in the given string.");return i.substring(0,n)}function b(e){const t=e.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/,"").split(/\}\r\n *\{/);return 1===t.length?t:"["+t.join("},{")+"]"}!function(){const e=[];for(const t in u)d[u[t]]=t,e.push(u[t]);e.reverse(),l=new RegExp(e.join("|"),"g")}();const w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function x(e,t){return e[0]+"="+e[1]+"; Path="+e[3]+"; Domain="+t+".com"}function I(e){return Object.prototype.toString.call(e).slice(8,-1)}module.exports={isReadableStream:function(e){return e instanceof a.Stream&&("Function"===I(e._read)||"AsyncFunction"===I(e._read))&&"Object"===I(e._readableState)},get:o,post:m,postFormData:c,generateThreadingID:function(e){return"<"+Date.now()+":"+Math.floor(4294967295*Math.random())+"-"+e+"@mail.projektitan.com>"},generateOfflineThreadingID:function(){const e=Date.now(),t=("0000000000000000000000"+Math.floor(4294967295*Math.random()).toString(2)).slice(-22);return function(e){let t="";for(;"0"!==e;){let a=0,r="",i=0;for(;i<e.length;i++)a=2*a+parseInt(e[i],10),a>=10?(r+="1",a-=10):r+="0";t=a.toString()+t,e=r.slice(r.indexOf("1"))}return t}(e.toString(2)+t)},getGUID:function(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const a=Math.floor((e+16*Math.random())%16);return e=Math.floor(e/16),("x"==t?a:7&a|8).toString(16)}))},getFrom:y,makeParsable:b,arrToForm:function(e){return t=function(e){return e.name},a=function(e){return e.val},e.reduce((function(e,r){return e[t(r)]=a(r),e}),{});var t,a},getSignatureID:function(){return Math.floor(2147483648*Math.random()).toString(16)},getJar:t.jar,generateTimestampRelative:function(){const e=new Date;return e.getHours()+":"+function(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e}(e.getMinutes())},makeDefaults:function(e,t,a){let r=1;const i=y(e,'name="fb_dtsg" value="','"');let n="2";for(let e=0;e<i.length;e++)n+=i.charCodeAt(e);const s=y(e,'revision":',",");function l(e){const o={__user:t,__req:(r++).toString(36),__rev:s,__a:1,fb_dtsg:a.fb_dtsg?a.fb_dtsg:i,jazoest:a.ttstamp?a.ttstamp:n};if(!e)return o;for(const t in e)e.hasOwnProperty(t)&&(o[t]||(o[t]=e[t]));return o}return{get:function(e,t,r,i,n={}){return o(e,t,l(r),a.globalOptions,i||a)},post:function(e,t,r,i,n={}){return m(e,t,l(r),a.globalOptions,i||a,n)},postFormData:function(e,t,r,i,n){return c(e,t,l(r),l(i),a.globalOptions,n||a)}}},parseAndCheckLogin:function t(a,i,n){return null==n&&(n=0),function(s){return e.try((function(){if(r.verbose("parseAndCheckLogin",s.body),s.statusCode>=500&&s.statusCode<600){if(n>=5){const e=new Error("Request retry failed. Check the `res` and `statusCode` property on this error.");throw e.statusCode=s.statusCode,e.res=s.body,e.error="Request retry failed. Check the `res` and `statusCode` property on this error.",e}n++;const o=Math.floor(5e3*Math.random());r.warn("parseAndCheckLogin","Got status code "+s.statusCode+" - "+n+". attempt to retry in "+o+" milliseconds...");const m=s.request.uri.protocol+"//"+s.request.uri.hostname+s.request.uri.pathname;return"multipart/form-data"===s.request.headers["Content-Type"].split(";")[0]?e.delay(o).then((function(){return i.postFormData(m,a.jar,s.request.formData,{})})).then(t(a,i,n)):e.delay(o).then((function(){return i.post(m,a.jar,s.request.formData)})).then(t(a,i,n))}if(200!==s.statusCode)throw new Error("parseAndCheckLogin got status code: "+s.statusCode+". Bailing out of trying to parse response.");let o=null;try{o=JSON.parse(b(s.body))}catch(e){const t=new Error("JSON.parse error. Check the `detail` property on this error.");throw t.error="JSON.parse error. Check the `detail` property on this error.",t.detail=e,t.res=s.body,t}if(o.redirect&&"GET"===s.request.method)return i.get(o.redirect,a.jar).then(t(a,i));if(o.jsmods&&o.jsmods.require&&Array.isArray(o.jsmods.require[0])&&"Cookie"===o.jsmods.require[0][0]){o.jsmods.require[0][3][0]=o.jsmods.require[0][3][0].replace("_js_","");const e=x(o.jsmods.require[0][3],"facebook"),t=x(o.jsmods.require[0][3],"messenger");a.jar.setCookie(e,"https://www.facebook.com"),a.jar.setCookie(t,"https://www.messenger.com")}if(o.jsmods&&Array.isArray(o.jsmods.require)){const e=o.jsmods.require;for(const t in e)if("DTSG"===e[t][0]&&"setToken"===e[t][1]){a.fb_dtsg=e[t][3][0],a.ttstamp="2";for(let e=0;e<a.fb_dtsg.length;e++)a.ttstamp+=a.fb_dtsg.charCodeAt(e)}}if(1357001===o.error){const e=new Error("Facebook blocked login. Please visit https://facebook.com and check your account.");throw e.error="Not logged in.",e}return o}))}},saveCookies:function(e){return function(t){return(t.headers["set-cookie"]||[]).forEach((function(t){t.indexOf(".facebook.com")>-1&&e.setCookie(t,"https://www.facebook.com");const a=t.replace(/domain=\.facebook\.com/,"domain=.messenger.com");e.setCookie(a,"https://www.messenger.com")})),t}},getType:I,_formatAttachment:g,formatHistoryMessage:function(e){return"ma-type:log-message"===e.action_type?function(e){const t=e.message?e.message:e;let a,r=t.log_message_type;return"log:generic-admin-text"===r?(a=t.log_message_data.untypedData,r=f(t.log_message_data.message_type)):a=t.log_message_data,Object.assign(_(t),{type:"event",logMessageType:r,logMessageData:a,logMessageBody:t.log_message_body})}(e):_(e)},formatID:h,formatMessage:_,formatDeltaEvent:function(e){let t,a;switch(e.class){case"AdminTextMessage":a=e.untypedData,t=f(e.type);break;case"ThreadName":t="log:thread-name",a={name:e.name};break;case"ParticipantsAddedToGroupThread":t="log:subscribe",a={addedParticipants:e.addedParticipants};break;case"ParticipantLeftGroupThread":t="log:unsubscribe",a={leftParticipantFbId:e.leftParticipantFbId};break;case"ApprovalQueue":t="log:approval-queue",a={approvalQueue:{action:e.action,recipientFbId:e.recipientFbId,requestSource:e.requestSource,...e.messageMetadata}}}return{type:"event",threadID:h((e.messageMetadata.threadKey.threadFbId||e.messageMetadata.threadKey.otherUserFbId).toString()),messageID:e.messageMetadata.messageId.toString(),logMessageType:t,logMessageData:a,logMessageBody:e.messageMetadata.adminText,timestamp:e.messageMetadata.timestamp,author:e.messageMetadata.actorFbId,participantIDs:e.participants||[]}},formatDeltaMessage:function(e){const t=e.delta.messageMetadata,a=void 0===e.delta.data||void 0===e.delta.data.prng?[]:JSON.parse(e.delta.data.prng),r=a.map((e=>e.i)),i=a.map((e=>e.o)),n=a.map((e=>e.l)),s={};for(let t=0;t<r.length;t++)s[r[t]]=e.delta.body.substring(i[t],i[t]+n[t]);return{type:"message",senderID:h(t.actorFbId.toString()),body:e.delta.body||"",threadID:h((t.threadKey.threadFbId||t.threadKey.otherUserFbId).toString()),messageID:t.messageId,attachments:(e.delta.attachments||[]).map((e=>g(e))),mentions:s,timestamp:t.timestamp,isGroup:!!t.threadKey.threadFbId,participantIDs:e.delta.participants||[]}},formatProxyPresence:function(e,t){return void 0===e.lat||void 0===e.p?null:{type:"presence",timestamp:1e3*e.lat,userID:t,statuses:e.p}},formatPresence:function(e,t){return{type:"presence",timestamp:1e3*e.la,userID:t,statuses:e.a}},formatTyp:function(e){return{isTyping:!!e.st,from:e.from.toString(),threadID:h((e.to||e.thread_fbid||e.from).toString()),fromMobile:!e.hasOwnProperty("from_mobile")||e.from_mobile,userID:(e.realtime_viewer_fbid||e.from).toString(),type:"typ"}},formatDeltaReadReceipt:function(e){return{reader:(e.threadKey.otherUserFbId||e.actorFbId).toString(),time:e.actionTimestampMs,threadID:h((e.threadKey.otherUserFbId||e.threadKey.threadFbId).toString()),type:"read_receipt"}},formatCookie:x,formatThread:function(e){return{threadID:h(e.thread_fbid.toString()),participants:e.participants.map(h),participantIDs:e.participants.map(h),name:e.name,nicknames:e.custom_nickname,snippet:e.snippet,snippetAttachments:e.snippet_attachments,snippetSender:h((e.snippet_sender||"").toString()),unreadCount:e.unread_count,messageCount:e.message_count,imageSrc:e.image_src,timestamp:e.timestamp,serverTimestamp:e.server_timestamp,muteUntil:e.mute_until,isCanonicalUser:e.is_canonical_user,isCanonical:e.is_canonical,isSubscribed:e.is_subscribed,folder:e.folder,isArchived:e.is_archived,recipientsLoadable:e.recipients_loadable,hasEmailParticipant:e.has_email_participant,readOnly:e.read_only,canReply:e.can_reply,cannotReplyReason:e.cannot_reply_reason,lastMessageTimestamp:e.last_message_timestamp,lastReadTimestamp:e.last_read_timestamp,lastMessageType:e.last_message_type,emoji:e.custom_like_icon,color:e.custom_color,adminIDs:e.admin_ids,threadType:e.thread_type}},formatReadReceipt:function(e){return{reader:e.reader.toString(),time:e.time,threadID:h((e.thread_fbid||e.reader).toString()),type:"read_receipt"}},formatRead:function(e){return{threadID:h((e.chat_ids&&e.chat_ids[0]||e.thread_fbids&&e.thread_fbids[0]).toString()),time:e.timestamp,type:"read"}},generatePresence:function(e){const t=Date.now();return"E"+(a=JSON.stringify({v:3,time:parseInt(t/1e3,10),user:e,state:{ut:0,t2:[],lm2:null,uct2:t,tr:null,tw:Math.floor(4294967295*Math.random())+1,at:t},ch:{["p_"+e]:0}}),encodeURIComponent(a).replace(/([_A-Z])|%../g,(function(e,t){return t?"%"+t.charCodeAt(0).toString(16):e})).toLowerCase().replace(l,(function(e){return d[e]})));var a},generateAccessiblityCookie:function(){const e=Date.now();return encodeURIComponent(JSON.stringify({sr:0,"sr-ts":e,jk:0,"jk-ts":e,kb:0,"kb-ts":e,hcm:0,"hcm-ts":e}))},formatDate:function(e){let t=e.getUTCDate();t=t>=10?t:"0"+t;let a=e.getUTCHours();a=a>=10?a:"0"+a;let r=e.getUTCMinutes();r=r>=10?r:"0"+r;let i=e.getUTCSeconds();return i=i>=10?i:"0"+i,v[e.getUTCDay()]+", "+t+" "+w[e.getUTCMonth()]+" "+e.getUTCFullYear()+" "+a+":"+r+":"+i+" GMT"},decodeClientPayload:function(e){return JSON.parse(String.fromCharCode.apply(null,e))},getAppState:function(e){return e.getCookies("https://www.facebook.com").concat(e.getCookies("https://facebook.com")).concat(e.getCookies("https://www.messenger.com"))},getAdminTextMessageType:f,setProxy:function(a){return t=e.promisify(void 0===a?require("request").defaults({jar:!0}):require("request").defaults({jar:!0,proxy:a}))}};