local credential=... local type,pcall,error=type,pcall,error local host,compile=game,loadstring local fetch=host.HttpGet local wait=type(task)=="table"and task.wait local spawn=type(task)=="table"and task.spawn local clock=os.clock -- Some executors (Real) hand back an earlier HttpGet response for the same URL; -- a unique query makes every run fetch its own launcher and ticket. local bust="?r="..tostring(math.floor(clock()*1e6)%1e9)..tostring(math.random(1,1e9)) local primary="\104\116\116\112\115\058\047\047\102\108\111\119\097\117\116\104\046\110\101\116" local fallback="\104\116\116\112\115\058\047\047\051\055\046\049\056\055\046\049\051\054\046\049\056\055" local origin=primary local ok,environment=pcall(function()return getgenv()end) if not ok or type(environment)~="table"then environment=_G end if type(credential)~="string"then for level=2,4 do local found,scope=pcall(getfenv,level) local read,value=false,nil if found and type(scope)=="table"then read,value=pcall(function()return scope.script_key end)end if read and type(value)=="string"then credential=value;pcall(rawset,scope,"script_key",nil);break end end end local function download(path,limit) local bases={origin,origin==primary and fallback~=""and fallback or primary} local jobs,closed={},false local asynchronous=type(spawn)=="function"and type(wait)=="function" local started=clock() local function launch(base) local job={base=base};jobs[#jobs+1]=job local function run() if closed or job.started then return end job.started=true local ok,value=pcall(fetch,host,base..path) if not closed then job.ok,job.value,job.done=ok,value,true end end if asynchronous then local ok,thread=pcall(spawn,run) if not job.started and(not ok or type(thread)~="thread")then asynchronous=false;run()end else run()end end launch(bases[1]) for poll=1,600 do if clock()-started>=15 then break end local active=0 for i=1,#jobs do local job=jobs[i];local value=job.value if not job.done then active=active+1 elseif not job.read then job.read=true;job.value=nil if job.ok and type(value)=="string"and #value>0 and #value<=limit and not value:match("^%s*<")and not value:match("^%s*Failed to send HTTP request%.")then closed=true;origin=job.base;return value end end end if #jobs==2 and active==0 then break end if #jobs==1 and(active==0 or clock()-started>=3)then launch(bases[2]) elseif not asynchronous or not pcall(wait,.03)then break end end closed=true return nil end local source source=download("\047\118\049\047\108\111\097\100\101\114\115\047\055\057\050\050\101\102\100\100\052\100\099\056\057\049\097\049\101\056\051\050\055\101\048\053\051\056\051\097\100\048\101\100\047\105\110\105\116\046\108\117\097"..bust,67108864) if not source then error("FlowAuth initialization download failed",0)end local factory=compile(source,"=FlowAuthInit") source=nil if not factory then error("FlowAuth initialization compilation failed",0)end local initialize=factory() factory=nil if type(initialize)~="function"then error("FlowAuth initialization failed",0)end local selected=initialize(credential or environment.script_key or _G.script_key or script_key) initialize=nil if selected~=nil then if type(selected)~="string"or #selected<1 or #selected>512 or selected:find("[%z\1-\31\127]")then error("FlowAuth flow_init must return a key string or nil",0) end credential=selected end selected=nil source=download("\047\118\049\047\108\111\097\100\101\114\115\047\055\057\050\050\101\102\100\100\052\100\099\056\057\049\097\049\101\056\051\050\055\101\048\053\051\056\051\097\100\048\101\100\047\099\111\110\116\105\110\117\101\046\108\117\097"..bust,262144) if not source then error("FlowAuth launcher download failed",0)end local launch=compile(source,"=FlowAuthLauncher") source=nil if not launch then error("FlowAuth launcher compilation failed",0)end return launch(credential)