From 817f7234a2af71286026af11bc69561a6af155f3 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 15 May 2015 11:27:44 -0700 Subject: [PATCH 1/4] web dependency tracking injection --- base/arvo/eyre.hoon | 33 +++++++++++++++++++++++++++++---- base/arvo/ford.hoon | 10 +++++++++- base/arvo/zuse.hoon | 1 + base/lib/urb.js | 11 +++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index 741e2ed11..21c9d5668 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -184,9 +184,11 @@ hit(q (weld cuh q.hit)) :: ++ add-poll :: inject dependency - |= [dep=@uvH max=[[%html ~] [[%head ~] hed=marl] [[%body ~] manx marl] ~]] + |= [dep=@uvH max=[[%html ~] [[%head ~] hed=marl] [[%body ~] tal=marl] ~]] ^- manx - =. hed.max :_(hed.max ;meta(charset "utf-8", urb_injected "");) + =: hed.max :_(hed.max ;meta(charset "utf-8", urb_injected "");) + tal.max (welp tal.max ;script(urb_injected ""):"{(trip etag:js)}" ~) + == ?~ dep max max(hed :_(hed.max ;script@"/~/on/{}.js"(urb_injected "");)) :: @@ -294,6 +296,28 @@ function(){document.getElementById("c").innerHTML = "

Goodbye.

" } )} ''' + ++ etag + ''' + if(!window.urb) window.urb = {} + urb.fetchTag = function(){ + var tag = JSON.parse(this.getResponseHeader("etag")) + if(tag) urb.wasp(tag) + } + urb.headReq = function(url){ + var xhr = new XMLHttpRequest() + xhr.open("HEAD", url) + xhr.onload = urb.fetchTag + xhr.send() + } + Array.prototype.map.call(document.querySelectorAll('script'), function(ele){ + if((new URL(ele.src)).host == document.location.host) + urb.headReq(ele.src) + }) + Array.prototype.map.call(document.querySelectorAll('link'), function(ele){ + if((new URL(ele.href)).host == document.location.host) + urb.headReq(ele.href) + }) + ''' -- ++ xml |% @@ -582,7 +606,7 @@ (~(has in aut.u.cyz) our) :: ++ ses-ya |=(ses=hole ~(. ya ses (~(got by wup) ses))) - ++ our-host `hart`[& ~ `/com/urbit/(rsh 3 1 (scot %p our))] + ++ our-host `hart`[& ~ `/org/urbit/(rsh 3 1 (scot %p our))] :: [| [~ 8.445] `/localhost] :: XX testing :: ++ ames-gram @@ -590,7 +614,8 @@ :: ++ back :: %ford bounce |= [tea=whir dep=@uvH mar=mark cay=cage] - (pass-note tea (ford-req root-beak [%cast mar %done ~ cay])) :: XX deps + =+ sil=`silk`[%cast mar %flag dep %done ~ cay] + (pass-note tea (ford-req root-beak sil)) :: ++ ford-kill (pass-note ~ %f [%exec our *beak ~]) :: XX unused ++ ford-req |=([bek=beak kas=silk] [%f [%exec our bek `kas]]) diff --git a/base/arvo/ford.hoon b/base/arvo/ford.hoon index f1c4a696c..1d1637291 100644 --- a/base/arvo/ford.hoon +++ b/base/arvo/ford.hoon @@ -1111,9 +1111,17 @@ $(kas [%done p.kas u.q.kas]) :: %file - %+ cool |.(leaf/"ford: file {}") (lear cof p.kas) + :: + %flag + ?~ p.kas $(kas q.kas) + =+ dap=(~(get by deh.bay) p.kas) + ?~ dap ~&(flag-missed/p.kas $(kas q.kas)) + =+ dep=?-(-.u.dap %init p.u.dap, %sent q.u.dap, %done [[bek ~] ~ ~]) + =+ rez=$(kas q.kas) :: XX revisit ^ during dependency review + ?: ?=(%1 -.q.rez) rez + rez(p.q (~(uni in p.q.rez) `(set beam)`dep)) :: %join %+ cool diff --git a/base/arvo/zuse.hoon b/base/arvo/zuse.hoon index f8fadd68c..9175dccfe 100644 --- a/base/arvo/zuse.hoon +++ b/base/arvo/zuse.hoon @@ -2475,6 +2475,7 @@ [%dude p=tank q=silk] :: error wrap [%dune p=(set beam) q=(unit gage)] :: unit literal [%file p=beam] :: from clay + [%flag p=@uvH q=silk] :: re-apply user deps [%join p=mark q=silk r=silk] :: merge [%mash p=mark q=milk r=milk] :: annotate [%mute p=silk q=(list (pair wing silk))] :: mutant diff --git a/base/lib/urb.js b/base/lib/urb.js index 215d39ef4..556459aa0 100644 --- a/base/lib/urb.js +++ b/base/lib/urb.js @@ -52,6 +52,17 @@ window.urb.req = function(method,url,params,json,cb) { xhr.send(JSON.stringify(_data)) } +// window.urb.getJSON = function(url,cb){ window.urb.reqJSON("GET",url, null, cb)} +// window.urb.reqJSON = function(method, url, data, cb){ +// var xhr = new XMLHttpRequest() +// xhr.open(method, url) +// xhr.onload = function(){ +// urb.fetchTag.call(xhr) +// if(cb) cb(JSON.parse(xhr.responseText)) +// } +// xhr.send(data === null ? null : JSON.stringify(data)) +// } + window.urb.reqq = [] window.urb.qreq = function(method,url,params,json,cb) { walk = function() { From e63ea914ababe7d88ceb56058bcb67e0ca832e31 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Fri, 15 May 2015 12:36:56 -0700 Subject: [PATCH 2/4] eyre blocking css --- base/arvo/eyre.hoon | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index 741e2ed11..92f310bbd 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -299,25 +299,19 @@ |% ++ login-page %+ titl 'Log in' - ;= ;div#c - ;p: Please log in. - ;p.mono: ~;{span#ship(contenteditable "")} - ;input#pass(onchange "urb.submit()"); - ;pre:code#err; - ;script@"/~/at/~/auth.js"; - == - ;link(rel "stylesheet", href "/home/lib/base.css"); + ;= ;p: Please log in. + ;p.mono: ~;{span#ship(contenteditable "")} + ;input#pass(onchange "urb.submit()"); + ;pre:code#err; + ;script@"/~/at/~/auth.js"; == :: ++ logout-page %+ titl 'Log out' - ;= ;div#c - ;p: Goodbye ~;{span#ship}. - ;button#act(onclick "urb.away()"): Log out - ;pre:code#err; - ;script@"/~/at/~/auth.js"; - == - ;link(rel "stylesheet", href "/home/lib/base.css"); + ;= ;p: Goodbye ~;{span#ship}. + ;button#act(onclick "urb.away()"): Log out + ;pre:code#err; + ;script@"/~/at/~/auth.js"; == :: ++ poke-test @@ -333,7 +327,15 @@ } ''' == - ++ titl |=([a=cord b=marl] ;html:(head:title:"{(trip a)}" body:"*{b}")) + ++ titl + |= [a=cord b=marl] + ;html + ;head + ;title:"{(trip a)}" + ;link(rel "stylesheet", href "/home/lib/base.css"); + == + ;body:div#c:"*{b}" + == -- -- |% :: functions From 67003df527565e2efb6e9a5787a79ae125beb2f0 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 15 May 2015 14:01:19 -0700 Subject: [PATCH 3/4] restore authentication to /~/at injection --- base/arvo/eyre.hoon | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index 379f1a0cc..304a3a777 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -409,7 +409,7 @@ =. p.p.pul |(p.p.pul ?=(hoke r.p.pul)) =+ her=(host-to-ship r.p.pul) ?: |(?=(~ her) =(our u.her)) - (handle pul [q.+.kyz anon] [p.heq maf s.heq]) + (handle pul [q.+.kyz |] [p.heq maf s.heq]) =+ han=(sham hen) =. pox (~(put by pox) han hen) (ames-gram u.her [%get ~] han +.kyz) @@ -667,7 +667,7 @@ :: ++ handle |= $: [hat=hart pok=pork quy=quay] :: purl, parsed url - [cip=clip him=ship] :: client ip, ship + [cip=clip aut=?] :: client ip, nonymous? [mef=meth maf=math bod=(unit octs)] :: method/headers/body == =< apex @@ -683,7 +683,9 @@ :: ++ ford-get-beam |= [bem=beam ext=term] - =: s.bem [%web ~(rent co (fcgi quy fcgi-cred:for-client)) s.bem] + =+ yac=for-client + =. him.yac ?.(aut anon him.yac) + =: s.bem [%web ~(rent co (fcgi quy fcgi-cred.yac)) s.bem] r.bem ?+(r.bem r.bem [%ud %0] da/now) == (ford-req -.bem [%boil ext bem ~]) @@ -906,7 +908,8 @@ =+ ext=(fall p.pok %urb) =+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem]) =+ wir=?+(mef !! %get ~, %head [%he ~]) - [%& %| wir (ford-get-beam bem ext)] + =- ?.(aut [%& %| -] [%| (pass-note -)]) :: XX properly + [wir (ford-get-beam bem ext)] :: %bugs ?- p.hem @@ -984,7 +987,8 @@ %get ~| aute/ham ?: |(=(anon him.ham) (~(has in aut.yac) him.ham)) - process(him him.ham, pok rem.ham) + =. aut & + process(pok rem.ham, ..ya abet.yac(him him.ham)) ?. =(our him.ham) [%| ((teba foreign-auth.yac) him.ham hat rem.ham quy)] (show-login-page ~) @@ -1025,7 +1029,7 @@ ?~ cyz ~& bad-cookie/u.lig (new-ya (rsh 3 1 (scot %p (end 6 1 ney)))) - ~(. ya u.lig u.cyz(him him, cug ~)) + ~(. ya u.lig u.cyz(cug ~)) :: ++ new-ya |=(ses=hole ~(. ya ses (new-cyst ses))) ++ new-cyst @@ -1158,7 +1162,6 @@ :: ++ del-subs :: XX per path? |= [a=dock %json b=wire c=path] ^+ ..ix - ~& [%eyre-del-subs +< hen] =. ..ix (hurl-note [a b] [%g %deal [him -.a] +.a %pull ~]) (nice-json:pop-duct:(ire-ix ire)) :: XX gall ack :: From 17df698c70b6a10aef83e76346f051ed8daf3b38 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 15 May 2015 16:21:09 -0700 Subject: [PATCH 4/4] remember logins --- base/arvo/eyre.hoon | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index 096ad9646..1bd5af7d3 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -653,8 +653,8 @@ ++ host-to-ship :: host to ship |= hot=host ^- (unit ship) - =+ gow=(~(get by dop) hot) - ?^ gow gow + :: =+ gow=(~(get by dop) hot) :: XX trust + :: ?^ gow gow ?. ?=(& -.hot) ~ =+ dom=(flop p.hot) :: domain name ?~ dom ~ @@ -989,8 +989,10 @@ %get ~| aute/ham ?: |(=(anon him.ham) (~(has in aut.yac) him.ham)) - =. aut & - process(pok rem.ham, ..ya abet.yac(him him.ham)) + =. ..ya abet.yac(him him.ham) + =+ pez=process(pok rem.ham, aut &) + ?: ?=(%| -.pez) pez + [%| (resolve ~ p.pez)] ?. =(our him.ham) [%| ((teba foreign-auth.yac) him.ham hat rem.ham quy)] (show-login-page ~)