fca-umaru-v1 40.1.25 → 40.1.26
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
const e=require("./utils"),t=require("cheerio"),o=require("npmlog"),$ = logger;let n=null;function i(t,n){Object.keys(n).map((function(i){switch(i){case"online":t.online=Boolean(n.online);break;case"logLevel":o.level=n.logLevel,t.logLevel=n.logLevel;break;case"logRecordSize":o.maxRecordSize=n.logRecordSize,t.logRecordSize=n.logRecordSize;break;case"selfListen":t.selfListen=Boolean(n.selfListen);break;case"selfListenEvent":t.selfListenEvent=n.selfListenEvent;break;case"listenEvents":t.listenEvents=Boolean(n.listenEvents);break;case"pageID":t.pageID=n.pageID.toString();break;case"updatePresence":t.updatePresence=Boolean(n.updatePresence);break;case"forceLogin":t.forceLogin=Boolean(n.forceLogin);break;case"userAgent":t.userAgent=n.userAgent;break;case"autoMarkDelivery":t.autoMarkDelivery=Boolean(n.autoMarkDelivery);break;case"autoMarkRead":t.autoMarkRead=Boolean(n.autoMarkRead);break;case"listenTyping":t.listenTyping=Boolean(n.listenTyping);break;case"proxy":"string"!=typeof n.proxy?(delete t.proxy,e.setProxy()):(t.proxy=n.proxy,e.setProxy(t.proxy));break;case"autoReconnect":t.autoReconnect=Boolean(n.autoReconnect);break;case"emitReady":t.emitReady=Boolean(n.emitReady);break;default:$.log("setOptions","Unrecognized option given to setOptions: "+i)}}))}function r(a,s,c,l,g,u){let p=null;const h=e.getJar();var d,f,m,w,k,b;a?(a.map((function(e){h.setCookie(e.key+"="+e.value+"; expires="+e.expires+"; domain="+e.domain+"; path="+e.path+";","http://"+e.domain)})),p=e.get("https://www.facebook.com/",h,null,l,{noRef:!0}).then(e.saveCookies(h))):p=e.get("https://www.facebook.com/",null,null,l,{noRef:!0}).then(e.saveCookies(h)).then((d=h,f=s,m=c,w=l,k=g,b=u,function(i){const a=i.body,s=t.load(a);let c=[];s("#login_form input").map((function(e,t){c.push({val:s(t).val(),name:s(t).attr("name")})})),c=c.filter((function(e){return e.val&&e.val.length}));const l=e.arrToForm(c);return l.lsd=e.getFrom(a,'["LSD",[],{"token":"','"}'),l.lgndim=Buffer.from('{"w":1440,"h":900,"aw":1440,"ah":834,"c":24}').toString("base64"),l.email=f,l.pass=m,l.default_persistent="0",l.lgnrnd=e.getFrom(a,'name="lgnrnd" value="','"'),l.locale="en_US",l.timezone="240",l.lgnjs=~~(Date.now()/1e3),a.split('"_js_').slice(1).map((function(t){const o=JSON.parse('["'+e.getFrom(t,"","]")+"]");d.setCookie(e.formatCookie(o,"facebook"),"https://www.facebook.com")})),$.log("Umaru","Logging in..."),e.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",d,l,w).then(e.saveCookies(d)).then((function(i){const a=i.headers;if(!a.location)throw{error:"Wrong username/password."};if(a.location.indexOf("https://www.facebook.com/checkpoint/")>-1){$.log("Umaru","You have login approvals turned on.");const i="https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php";return e.get(a.location,d,null,w).then(e.saveCookies(d)).then((function(a){const s=a.body,c=t.load(s);let l=[];c("form input").map((function(e,t){l.push({val:c(t).val(),name:c(t).attr("name")})})),l=l.filter((function(e){return e.val&&e.val.length}));const g=e.arrToForm(l);if(s.indexOf("checkpoint/?next")>-1)throw setTimeout((()=>{n=setInterval((e=>{}),5e3,{fb_dtsg:g.fb_dtsg,jazoest:g.jazoest,dpr:1})}),2500),{error:"login-approval",continue:function a(s){g.approvals_code=s,g["submit[Continue]"]=c("#checkpointSubmitButton").html();let l=null,u=null;const p=new Promise((function(e,t){l=e,u=t}));return"string"==typeof s?e.post(i,d,g,w).then(e.saveCookies(d)).then((function(e){const o=t.load(e.body)("#approvals_code").parent().attr("data-xui-error");if(o)throw{error:"login-approval",errordesc:"Invalid 2FA code.",lerror:o,continue:a}})).then((function(){return delete g.no_fido,delete g.approvals_code,g.name_action_selected="dont_save",e.post(i,d,g,w).then(e.saveCookies(d))})).then((function(t){if(!t.headers.location&&t.body.indexOf("Review Recent Login")>-1)throw{error:"Something went wrong with login approvals."};const o=e.getAppState(d);return k===b&&(k=function(e,t){return e?u(e):l(t)}),r(o,f,m,w,k)})).catch((function(e){k===b?u(e):k(e)})):e.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",d,g,w,null,{Referer:"https://www.facebook.com/checkpoint/?next"}).then(e.saveCookies(d)).then((t=>{try{JSON.parse(t.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/,""))}catch(t){return clearInterval(n),$.log("Umaru","Verified from browser. Logging in..."),k===b&&(k=function(e,t){return e?u(e):l(t)}),r(e.getAppState(d),f,m,w,k)}})).catch((e=>{$.log("Umaru",e),k===b?u(e):k(e)})),p}};if(!w.forceLogin)throw{error:"Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again."};return s.indexOf("Suspicious Login Attempt")>-1?g["submit[This was me]"]="This was me":g["submit[This Is Okay]"]="This Is Okay",e.post(i,d,g,w).then(e.saveCookies(d)).then((function(){return g.name_action_selected="save_device",e.post(i,d,g,w).then(e.saveCookies(d))})).then((function(t){if(!t.headers.location&&t.body.indexOf("Review Recent Login")>-1)throw{error:"Something went wrong with review recent login."};return r(e.getAppState(d),f,m,w,k)})).catch((function(e){k(e)}))}))}return e.get("https://www.facebook.com/",d,null,w).then(e.saveCookies(d))}))})).then((function(){return e.get("https://www.facebook.com/",h,null,l).then(e.saveCookies(h))}));let v=null,y=null,S=null;p=p.then((function(t){const o=/<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/.exec(t.body);return o&&o[1]?e.get(o[1],h,null,l).then(e.saveCookies(h)):t})).then((function(t){const r=function(t,r,a){const s=a.getCookies("https://www.facebook.com").filter((function(e){return"c_user"===e.cookieString().split("=")[0]})),c=a.getCookies("https://www.facebook.com").reduce((function(e,t){return e[t.cookieString().split("=")[0]]=t.cookieString().split("=")[1],e}),{});if(0===s.length)throw{error:"Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify."};r.indexOf("/checkpoint/block/?next")>-1&&$.log("Umaru","Checkpoint detected. Please log in with a browser to verify.");const l=s[0].cookieString().split("=")[1].toString(),g=c.i_user||null;$.log("Umaru","Logged in as "+l);try{clearInterval(n)}catch(e){}const u=(2147483648*Math.random()|0).toString(16),p=r.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);let h=null,d=null,f=null,m=null;if(p)f=p[1],h=p[2],d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Got this account's message region: "+d);else{const e=r.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);if(e)f=e[2],h=e[1].replace(/\\\//g,"/"),d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Got this account's message region: "+d);else{const e=r.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);e?(h=e[4],d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)..."),$.log("Umaru","Got this account's message region: "+d),$.log("Umaru","[Unused] Polling endpoint: "+e[6])):($.log("Umaru","Cannot get MQTT region & sequence ID."),m=r)}}const w={userID:l,i_userID:g,jar:a,clientID:u,globalOptions:t,loggedIn:!0,access_token:"NONE",clientMutationId:0,mqttClient:void 0,lastSeqId:f,syncToken:void 0,mqttEndpoint:h,region:d,firstListen:!0},k={setOptions:i.bind(null,t),getAppState:function(){return e.getAppState(a).filter(((e,t,o)=>o.findIndex((t=>t.key===e.key))===t))}};m&&(k.htmlData=m);const b=e.makeDefaults(r,g||l,w);return["addExternalModule","addUserToGroup","changeAdminStatus","changeArchivedStatus","changeAvatar","changeBio","changeBlockedStatus","changeGroupImage","changeNickname","changeThreadColor","changeThreadEmoji","createNewGroup","createPoll","deleteMessage","deleteThread","forwardAttachment","getAccessToken","getCurrentUserID","getEmojiUrl","getFriendsList","getMessage","getThreadHistory","getThreadInfo","getThreadList","getThreadPictures","getUserID","getUserInfo","handleMessageRequest","listenMqtt","logout","markAsDelivered","markAsRead","markAsReadAll","markAsSeen","muteThread","removeUserFromGroup","resolvePhotoUrl","searchForThread","sendMessage","sendTypingIndicator","setMessageReaction","setPostReaction","setTitle","threadColors","unsendMessage","httpGet","httpPost","httpPostFormData","uploadAttachment"].map((function(e){k[e]=require("./src/"+e)(b,k,w)})),k.listen=k.listenMqtt,[w,b,k]}(l,t.body,h);return v=r[0],y=r[1],S=r[2],t})),l.pageID&&(p=p.then((function(){return e.get("https://www.facebook.com/"+v.globalOptions.pageID+"/messages/?section=messages&subsection=inbox",v.jar,null,l)})).then((function(t){let o=e.getFrom(t.body,'window.location.replace("https:\\/\\/www.facebook.com\\','");').split("\\").join("");return o=o.substring(0,o.length-1),e.get("https://www.facebook.com"+o,v.jar,null,l)}))),p.then((function(){return $.log("Umaru","Done logging in."),g(null,S)})).catch((function(e){$.log("Umaru",e.error||e),g(e)}))}o.maxRecordSize=100,module.exports=function(t,o,n){"Function"!==e.getType(o)&&"AsyncFunction"!==e.getType(o)||(n=o,o={});const a={selfListen:!1,selfListenEvent:!1,listenEvents:!1,listenTyping:!1,updatePresence:!1,forceLogin:!1,autoMarkDelivery:!0,autoMarkRead:!1,autoReconnect:!0,logRecordSize:100,online:!0,emitReady:!1,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"};i(a,o);let s=null;if("Function"!==e.getType(n)&&"AsyncFunction"!==e.getType(n)){let e=null,t=null;var c=new Promise((function(o,n){t=o,e=n}));s=function(o,n){return o?e(o):t(n)},n=s}return r(t.appState,t.email,t.password,a,n,s),c};
|
1
|
+
const e=require("./utils"),t=require("cheerio"),o=require("npmlog"),$ = logger;let n=null;function i(t,n){Object.keys(n).map((function(i){switch(i){case"online":t.online=Boolean(n.online);break;case"logLevel":o.level=n.logLevel,t.logLevel=n.logLevel;break;case"logRecordSize":o.maxRecordSize=n.logRecordSize,t.logRecordSize=n.logRecordSize;break;case"selfListen":t.selfListen=Boolean(n.selfListen);break;case"selfListenEvent":t.selfListenEvent=n.selfListenEvent;break;case"listenEvents":t.listenEvents=Boolean(n.listenEvents);break;case"pageID":t.pageID=n.pageID.toString();break;case"updatePresence":t.updatePresence=Boolean(n.updatePresence);break;case"forceLogin":t.forceLogin=Boolean(n.forceLogin);break;case"userAgent":t.userAgent=n.userAgent;break;case"autoMarkDelivery":t.autoMarkDelivery=Boolean(n.autoMarkDelivery);break;case"autoMarkRead":t.autoMarkRead=Boolean(n.autoMarkRead);break;case"listenTyping":t.listenTyping=Boolean(n.listenTyping);break;case"proxy":"string"!=typeof n.proxy?(delete t.proxy,e.setProxy()):(t.proxy=n.proxy,e.setProxy(t.proxy));break;case"autoReconnect":t.autoReconnect=Boolean(n.autoReconnect);break;case"emitReady":t.emitReady=Boolean(n.emitReady);break;default:$.log("setOptions","Unrecognized option given to setOptions: "+i)}}))}function r(a,s,c,l,g,u){let p=null;const h=e.getJar();var d,f,m,w,k,b;a?(a.map((function(e){h.setCookie(e.key+"="+e.value+"; expires="+e.expires+"; domain="+e.domain+"; path="+e.path+";","http://"+e.domain)})),p=e.get("https://www.facebook.com/",h,null,l,{noRef:!0}).then(e.saveCookies(h))):p=e.get("https://www.facebook.com/",null,null,l,{noRef:!0}).then(e.saveCookies(h)).then((d=h,f=s,m=c,w=l,k=g,b=u,function(i){const a=i.body,s=t.load(a);let c=[];s("#login_form input").map((function(e,t){c.push({val:s(t).val(),name:s(t).attr("name")})})),c=c.filter((function(e){return e.val&&e.val.length}));const l=e.arrToForm(c);return l.lsd=e.getFrom(a,'["LSD",[],{"token":"','"}'),l.lgndim=Buffer.from('{"w":1440,"h":900,"aw":1440,"ah":834,"c":24}').toString("base64"),l.email=f,l.pass=m,l.default_persistent="0",l.lgnrnd=e.getFrom(a,'name="lgnrnd" value="','"'),l.locale="en_US",l.timezone="240",l.lgnjs=~~(Date.now()/1e3),a.split('"_js_').slice(1).map((function(t){const o=JSON.parse('["'+e.getFrom(t,"","]")+"]");d.setCookie(e.formatCookie(o,"facebook"),"https://www.facebook.com")})),$.log("Umaru","Logging in..."),e.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",d,l,w).then(e.saveCookies(d)).then((function(i){const a=i.headers;if(!a.location)throw{error:"Wrong username/password."};if(a.location.indexOf("https://www.facebook.com/checkpoint/")>-1){$.log("Umaru","You have login approvals turned on.");const i="https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php";return e.get(a.location,d,null,w).then(e.saveCookies(d)).then((function(a){const s=a.body,c=t.load(s);let l=[];c("form input").map((function(e,t){l.push({val:c(t).val(),name:c(t).attr("name")})})),l=l.filter((function(e){return e.val&&e.val.length}));const g=e.arrToForm(l);if(s.indexOf("checkpoint/?next")>-1)throw setTimeout((()=>{n=setInterval((e=>{}),5e3,{fb_dtsg:g.fb_dtsg,jazoest:g.jazoest,dpr:1})}),2500),{error:"login-approval",continue:function a(s){g.approvals_code=s,g["submit[Continue]"]=c("#checkpointSubmitButton").html();let l=null,u=null;const p=new Promise((function(e,t){l=e,u=t}));return"string"==typeof s?e.post(i,d,g,w).then(e.saveCookies(d)).then((function(e){const o=t.load(e.body)("#approvals_code").parent().attr("data-xui-error");if(o)throw{error:"login-approval",errordesc:"Invalid 2FA code.",lerror:o,continue:a}})).then((function(){return delete g.no_fido,delete g.approvals_code,g.name_action_selected="dont_save",e.post(i,d,g,w).then(e.saveCookies(d))})).then((function(t){if(!t.headers.location&&t.body.indexOf("Review Recent Login")>-1)throw{error:"Something went wrong with login approvals."};const o=e.getAppState(d);return k===b&&(k=function(e,t){return e?u(e):l(t)}),r(o,f,m,w,k)})).catch((function(e){k===b?u(e):k(e)})):e.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",d,g,w,null,{Referer:"https://www.facebook.com/checkpoint/?next"}).then(e.saveCookies(d)).then((t=>{try{JSON.parse(t.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/,""))}catch(t){return clearInterval(n),$.log("Umaru","Verified from browser. Logging in..."),k===b&&(k=function(e,t){return e?u(e):l(t)}),r(e.getAppState(d),f,m,w,k)}})).catch((e=>{$.log("Umaru",e),k===b?u(e):k(e)})),p}};if(!w.forceLogin)throw{error:"Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again."};return s.indexOf("Suspicious Login Attempt")>-1?g["submit[This was me]"]="This was me":g["submit[This Is Okay]"]="This Is Okay",e.post(i,d,g,w).then(e.saveCookies(d)).then((function(){return g.name_action_selected="save_device",e.post(i,d,g,w).then(e.saveCookies(d))})).then((function(t){if(!t.headers.location&&t.body.indexOf("Review Recent Login")>-1)throw{error:"Something went wrong with review recent login."};return r(e.getAppState(d),f,m,w,k)})).catch((function(e){k(e)}))}))}return e.get("https://www.facebook.com/",d,null,w).then(e.saveCookies(d))}))})).then((function(){return e.get("https://www.facebook.com/",h,null,l).then(e.saveCookies(h))}));let v=null,y=null,S=null;p=p.then((function(t){const o=/<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/.exec(t.body);return o&&o[1]?e.get(o[1],h,null,l).then(e.saveCookies(h)):t})).then((function(t){const r=function(t,r,a){const s=a.getCookies("https://www.facebook.com").filter((function(e){return"c_user"===e.cookieString().split("=")[0]})),c=a.getCookies("https://www.facebook.com").reduce((function(e,t){return e[t.cookieString().split("=")[0]]=t.cookieString().split("=")[1],e}),{});if(0===s.length)throw{error:"Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify."};r.indexOf("/checkpoint/block/?next")>-1&&$.log("Umaru","Checkpoint detected. Please log in with a browser to verify.");const l=s[0].cookieString().split("=")[1].toString(),g=c.i_user||null;$.log("Umaru","Logged in as "+l);try{clearInterval(n)}catch(e){}const u=(2147483648*Math.random()|0).toString(16),p=r.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);let h=null,d=null,f=null,m=null;if(p)f=p[1],h=p[2],d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Got this account's message region: "+d);else{const e=r.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);if(e)f=e[2],h=e[1].replace(/\\\//g,"/"),d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Got this account's message region: "+d);else{const e=r.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);e?(h=e[4],d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)..."),$.log("Umaru","Got this account's message region: "+d),$.log("Umaru","[Unused] Polling endpoint: "+e[6])):($.log("Umaru","Cannot get MQTT region & sequence ID."),m=r)}}const w={userID:l,i_userID:g,jar:a,clientID:u,globalOptions:t,loggedIn:!0,access_token:"NONE",clientMutationId:0,mqttClient:void 0,lastSeqId:f,syncToken:void 0,mqttEndpoint:h,region:d,firstListen:!0},k={setOptions:i.bind(null,t),getAppState:function(){return e.getAppState(a).filter(((e,t,o)=>o.findIndex((t=>t.key===e.key))===t))}};m&&(k.htmlData=m);const b=e.makeDefaults(r,g||l,w);return["addExternalModule","addUserToGroup","changeAdminStatus","changeArchivedStatus","changeAvatar","changeBio","changeBlockedStatus","changeGroupImage","changeNickname","changeThreadColor","changeThreadEmoji","createNewGroup","createPoll","deleteMessage","deleteThread","forwardAttachment","getAccessToken","getCurrentUserID","getEmojiUrl","getFriendsList","getMessage","getThreadHistory","getThreadInfo","getThreadList","getThreadPictures","getUserID","getUserInfo","handleMessageRequest","listenMqtt","logout","markAsDelivered","markAsRead","markAsReadAll","markAsSeen","muteThread","removeUserFromGroup","resolvePhotoUrl","searchForThread","sendMessage","sendTypingIndicator","setMessageReaction","setPostReaction","setTitle","threadColors","unsendMessage","httpGet","httpPost","httpPostFormData","uploadAttachment", "refreshFb_dtsg"].map((function(e){k[e]=require("./src/"+e)(b,k,w)})),k.listen=k.listenMqtt,[w,b,k]}(l,t.body,h);return v=r[0],y=r[1],S=r[2],t})),l.pageID&&(p=p.then((function(){return e.get("https://www.facebook.com/"+v.globalOptions.pageID+"/messages/?section=messages&subsection=inbox",v.jar,null,l)})).then((function(t){let o=e.getFrom(t.body,'window.location.replace("https:\\/\\/www.facebook.com\\','");').split("\\").join("");return o=o.substring(0,o.length-1),e.get("https://www.facebook.com"+o,v.jar,null,l)}))),p.then((function(){return $.log("Umaru","Done logging in."),g(null,S)})).catch((function(e){$.log("Umaru",e.error||e),g(e)}))}o.maxRecordSize=100,module.exports=function(t,o,n){"Function"!==e.getType(o)&&"AsyncFunction"!==e.getType(o)||(n=o,o={});const a={selfListen:!1,selfListenEvent:!1,listenEvents:!1,listenTyping:!1,updatePresence:!1,forceLogin:!1,autoMarkDelivery:!0,autoMarkRead:!1,autoReconnect:!0,logRecordSize:100,online:!0,emitReady:!1,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"};i(a,o);let s=null;if("Function"!==e.getType(n)&&"AsyncFunction"!==e.getType(n)){let e=null,t=null;var c=new Promise((function(o,n){t=o,e=n}));s=function(o,n){return o?e(o):t(n)},n=s}return r(t.appState,t.email,t.password,a,n,s),c};
|