shrub/arvo/eyre.hoon

1609 lines
55 KiB
Plaintext
Raw Normal View History

2015-07-07 22:51:25 +03:00
!: :: %eyre, http servant
2014-03-12 23:50:39 +04:00
!? 164
::::
2015-12-20 23:50:45 +03:00
|= pit/vase
2013-09-29 00:21:18 +04:00
=> =~
2014-06-07 22:36:31 +04:00
|% :: interfaces
++ gift gift-eyre :: out result <-$
++ kiss kiss-eyre :: in request ->$
2015-12-20 23:50:45 +03:00
++ move {p/duct q/(mold note gift)} :: local move
2014-06-03 09:07:32 +04:00
++ note :: out request $->
2015-12-14 10:58:14 +03:00
$% $: $a :: to %ames
2015-12-20 23:50:45 +03:00
$% {$wont p/sock q/{path *}} ::
== == ::
2015-12-14 10:58:14 +03:00
$: $b :: to %behn
2015-12-20 23:50:45 +03:00
$% {$wait p/@da} ::
{$rest p/@da} ::
2014-06-22 06:51:12 +04:00
== == ::
2015-12-14 10:58:14 +03:00
$: $d :: to %dill
2015-12-20 23:50:45 +03:00
$% {$flog p/{$crud p/@tas q/(list tank)}} ::
2014-06-22 06:51:12 +04:00
== == ::
2015-12-14 10:58:14 +03:00
$: $e :: to self
$% {$thud $~} :: proxied death
2015-12-20 23:50:45 +03:00
{$this p/? q/clip r/httq} :: proxied request
2015-12-06 07:50:40 +03:00
{$meta vase:{$them (unit httr)}} :: type check
2014-06-22 06:51:12 +04:00
== == ::
2015-12-14 10:58:14 +03:00
$: $f :: to %ford
2015-12-20 23:50:45 +03:00
$% {$exec p/@p q/(unit {beak silk})} ::
{$wasp p/@p q/@uvH r/?} ::
2014-06-22 06:51:12 +04:00
== == ::
2015-12-14 10:58:14 +03:00
$: $g :: to %gall
2015-12-20 23:50:45 +03:00
$% {$deal p/sock q/cush} :: full transmission
2014-06-22 06:51:12 +04:00
== == == ::
2014-06-22 09:49:10 +04:00
++ sign :: in result $<-
2015-12-14 10:58:14 +03:00
$? $: $a :: by %aformedmes
2015-12-20 23:50:45 +03:00
$% {$woot p/ship q/coop} ::
== == ::
2015-12-14 10:58:14 +03:00
$: $b :: by %behn
$% {$wake $~} :: timer activate
2015-05-08 23:27:40 +03:00
== == ::
2015-12-14 10:58:14 +03:00
$: $g :: by %gall
2015-12-20 23:50:45 +03:00
$% {$unto p/cuft} :: within agent
2014-06-22 06:51:12 +04:00
== == ::
2015-12-14 10:58:14 +03:00
$: $e :: by self
2015-12-20 23:50:45 +03:00
$% {$thou p/httr} :: response for proxy
2014-06-22 06:51:12 +04:00
== == ::
2015-12-14 10:58:14 +03:00
$: $f :: by %ford
2015-12-20 23:50:45 +03:00
$% {$made p/@uvH q/gage} ::
{$news p/@uvH} ::
2014-06-22 06:51:12 +04:00
== == ::
$: @tas :: by any
2015-12-20 23:50:45 +03:00
$% {$crud p/@tas q/(list tank)} ::
2014-06-22 06:51:12 +04:00
== == == ::
2015-12-06 07:50:40 +03:00
++ ixor @t :: oryx hash
2015-12-14 10:58:14 +03:00
++ whir $@ $~ :: wire subset
2015-12-20 23:50:45 +03:00
$% {$at p/hole q/whir} :: authenticated
{$ay p/knot:ship q/knot:@uvH $~} :: remote duct
2015-12-20 23:50:45 +03:00
{$ha p/path:beak} :: GET request
{$he p/whir} :: HEAD request
{$hi p/mark $~} :: outbound HTTP
2015-12-06 07:50:40 +03:00
{$si $~} :: response done
2015-12-20 23:50:45 +03:00
{$of p/ixor q/$@($~ whir-of)} :: associated view
{$ow p/ixor $~} :: dying view
2015-12-06 07:50:40 +03:00
{$on $~} :: dependency
2015-03-12 02:51:04 +03:00
== ::
++ whir-of {p/knot:ship q/term r/wire} :: path in dock
2014-06-22 06:51:12 +04:00
-- ::
2014-06-07 22:36:31 +04:00
|% :: models
2013-09-29 00:21:18 +04:00
++ bolo :: eyre state
$: $4 :: version
2015-12-20 23:50:45 +03:00
gub/@t :: random identity
hov/(unit ship) :: master for remote
top/beam :: ford serve prefix
2015-12-20 23:50:45 +03:00
ged/duct :: client interface
ded/(set duct) :: killed requests
lyv/(map duct live) :: living requests
pox/(map @uvH duct) :: proxied sessions
ask/{p/@ud q/(map @ud {p/duct q/hiss})} :: outgoing by number
kes/(map duct @ud) :: outgoing by duct
ney/@uvI :: rolling entropy
dop/(map host ship) :: host aliasing
liz/(jug @uvH (each duct ixor)) :: ford depsets
wup/(map hole cyst) :: secure sessions
sop/(map hole {ship ?}) :: foreign sess names
wix/(map ixor stem) :: open views
2014-04-16 05:35:25 +04:00
== ::
2015-03-03 04:52:55 +03:00
::
2015-12-01 05:02:41 +03:00
++ live :: in flight
2015-12-20 23:50:45 +03:00
$% {$exec p/whir} :: ford build
{$wasp p/(list @uvH)} :: ford deps
{$xeno p/ship} :: proxied request
{$poll p/ixor} :: session state
2015-12-01 05:02:41 +03:00
==
2014-03-12 23:50:39 +04:00
++ cyst :: client session
2015-12-20 23:50:45 +03:00
$: ced/cred :: credential
{him/ship aut/(set ship)} :: authenticated
cug/(list @t) :: unacked cookies
lax/@da :: last used
way/(map ship {purl duct}) :: waiting auth
vew/(set oryx) :: open views XX expire
2014-06-10 00:09:14 +04:00
== ::
2015-03-03 04:52:55 +03:00
::
2015-03-17 03:32:44 +03:00
++ stem :: client view
2015-12-20 23:50:45 +03:00
$: him/ship :: static identity
ude/(unit {p/duct q/?}) :: stream long-poll?
era/@da :: next wake
die/@da :: collection date
sus/(set {dock $json wire path}) :: subscriptions
eve/{p/@u q/(map @u even)} :: queued events
2016-02-11 03:41:28 +03:00
med/(qeu duct) :: waiting /~/to/
2015-03-17 03:32:44 +03:00
==
++ even :: client event
2015-12-20 23:50:45 +03:00
$% {$news p/@uvH}
{$quit p/{dock path}}
{$rush p/{dock path} q/json}
2015-03-17 03:32:44 +03:00
==
::
2015-03-03 04:52:55 +03:00
++ perk :: parsed request
2015-12-20 23:50:45 +03:00
$% {$auth p/perk-auth}
2015-12-06 07:50:40 +03:00
{$away $~}
2015-12-20 23:50:45 +03:00
{$bugs p/?($as $to) $~}
{$beam p/beam}
{$deps p/?($put $delt) q/@uvH}
{$mess p/dock q/mark r/wire s/json}
{$poll p/{i/@uvH t/(list @uvH)}}
{$spur p/spur}
{$subs p/?($put $delt) q/{dock $json wire path}}
{$view p/ixor q/{$~ u/@ud}}
2015-03-03 04:52:55 +03:00
==
::
++ perk-auth :: parsed auth
2015-12-20 23:50:45 +03:00
$% {$at p/pork} :: inject auth
{$del p/(unit ship)}
{$get him/ship rem/pork}
2015-12-06 07:50:40 +03:00
{$js $~}
{$json $~}
2015-12-20 23:50:45 +03:00
{$try him/ship paz/(unit cord)}
{$xen ses/hole rem/pork}
2015-03-03 04:52:55 +03:00
==
2015-03-04 05:22:02 +03:00
::
++ pest :: result
2015-12-14 10:58:14 +03:00
$@ $~
2015-12-20 23:50:45 +03:00
$% {$$ p/httr} :: direct response
2015-12-06 07:50:40 +03:00
{$red $~} :: parent redirect
{$bake p/whir q/mark r/coin s/beam} :: ford request
2015-12-20 23:50:45 +03:00
{$js p/@t} :: script
{$json p/json} :: data
{$html p/manx} :: successful page
{$htme p/manx} :: authentication fail
2015-03-04 05:22:02 +03:00
==
2014-03-12 23:50:39 +04:00
-- ::
|%
2015-03-28 04:06:38 +03:00
++ eat-headers
2015-12-20 23:50:45 +03:00
|= hed/(list {p/@t q/@t}) ^- math
2015-03-28 04:06:38 +03:00
%+ roll hed
|= {a/{p/cord q/cord} b/math}
2015-03-28 04:06:38 +03:00
=. p.a (cass (trip p.a))
(~(add ja b) p.a q.a)
2015-03-28 04:06:38 +03:00
::
++ fcgi :: credential caboose
2015-12-20 23:50:45 +03:00
|= {quy/quay ced/cred} ^- coin
:+ %many
[%blob ced]
|- ^- (list coin)
?~ quy [%$ %n ~]~
[[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)]
2015-03-28 04:06:38 +03:00
::
2015-12-20 23:50:45 +03:00
++ gsig |=({a/dock b/path} [(scot %p p.a) q.a b])
2015-03-09 23:55:54 +03:00
++ session-from-cookies
2015-12-20 23:50:45 +03:00
|= {nam/@t maf/math}
2014-03-20 05:05:42 +04:00
^- (unit hole)
2015-12-20 23:50:45 +03:00
(from-cookies maf |=({k/@t v/@} &(=(nam k) !=('~' v))))
2015-05-19 00:19:13 +03:00
::
++ ship-from-cookies
2015-12-20 23:50:45 +03:00
|= maf/math ^- (unit ship)
(biff (from-cookies maf |=({k/@ @} =(%ship k))) (slat %p))
2015-05-19 00:19:13 +03:00
::
++ from-cookies
2016-02-04 10:12:23 +03:00
|= {maf/math fil/$-({@t @t} ?)}
2015-12-20 23:50:45 +03:00
=+ `cot/(list @t)`(~(get ju maf) 'cookie')
=+ `cok/quay`(zing `(list quay)`(murn cot (curr rush cock:epur)))
2015-05-19 00:19:13 +03:00
|- ^- (unit cord)
2014-03-12 23:50:39 +04:00
?~ cok ~
2015-05-19 00:19:13 +03:00
?:((fil i.cok) [~ q.i.cok] $(cok t.cok))
2013-09-29 00:21:18 +04:00
::
2015-03-12 02:51:04 +03:00
++ wush
2015-12-20 23:50:45 +03:00
|= {wid/@u tan/tang}
2015-03-12 02:51:04 +03:00
^- tape
2015-12-20 23:50:45 +03:00
=+ rolt=|=(a/wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a))))
(rolt (turn tan |=(a/tank (rolt (wash 0^wid a)))))
2014-07-17 06:10:13 +04:00
::
2014-06-10 00:09:14 +04:00
::
2015-03-28 04:06:38 +03:00
++ add-cookies
2015-12-20 23:50:45 +03:00
|= {cug/(list @t) hit/httr} ^- httr
2015-03-28 04:06:38 +03:00
?~ cug hit
2015-12-21 00:16:39 +03:00
=+ cuh=(turn `(list @t)`cug |=(a/@t set-cookie+a))
2015-03-28 04:06:38 +03:00
hit(q (weld cuh q.hit))
2014-06-25 02:00:07 +04:00
::
2015-03-28 04:06:38 +03:00
++ add-json :: inject window.urb
2015-12-20 23:50:45 +03:00
|= {urb/json jaz/cord} ^- cord
=- (cat 3 (crip -) jaz)
"""
var _urb = {(pojo urb)}
window.urb = window.urb || \{}; for(k in _urb) window.urb[k] = _urb[k]
"""
2014-07-17 06:10:13 +04:00
::
2015-03-28 04:06:38 +03:00
++ ares-to-json
2015-12-20 23:50:45 +03:00
|= err/ares ^- json
2015-12-21 00:16:39 +03:00
=- (jobe fail+s+typ mess+(jape mez) ~)
2015-12-20 23:50:45 +03:00
^- {typ/term mez/tape}
2015-03-28 04:06:38 +03:00
?~ err [%fail "Unknown Error"]
[p.u.err (wush 160 q.u.err)]
2014-05-10 11:10:46 +04:00
::
2015-03-28 04:06:38 +03:00
++ resp :: mimed response
2015-12-20 23:50:45 +03:00
|= {sas/@uG mit/mite rez/@} ^- httr
2015-03-28 04:06:38 +03:00
:: (weld (turn cug |=(a=@t ['set-cookie' a]))
2015-12-21 00:16:39 +03:00
[sas ~[content-type+(moon mit)] [~ (taco rez)]]
2015-03-28 04:06:38 +03:00
::
++ render-tang :: tanks to manx
|= {dep/@uvH tan/tang}
2014-04-25 23:27:48 +04:00
;html
;head
2015-12-07 22:28:30 +03:00
;link(rel "stylesheet", href "/lib/base.css");
2015-02-17 02:19:58 +03:00
;title: server error
2014-04-25 23:27:48 +04:00
==
2015-04-09 20:05:03 +03:00
;body:div#c.err:pre:code:"{(wush 80 tan)}"
;script@"/~/on/{<dep>}.js";
2014-04-25 23:27:48 +04:00
==
::
2015-05-30 02:47:38 +03:00
++ favi :: XX favicon
2016-02-26 03:35:34 +03:00
%+ can 6 :~
[20 0wf~.~0000.00000.00000.00000.00000.1g000.00002.000g0.00200.000g0.
000a0.001kU.001gE.02000.g0082.00000.C0005.a00w0.04001.0g008.00g00]
::
[98 (fil 6 98 0w3.~~~~~)]
[59 0wf~~~Z.jkRf~.OYLb~.~~~~~.~~~~~.~Z~vT.~LrSZ.~SNIr.fZnlR.v~CVK.r~~LX.
-~~~~.~~~~~.~~~~~.~~~~~.~~~~~.~~~~~.rSZLY.Ib2P~.gA92~.XqSJL.-vDV~.~fzU-.
~M000.fY000.3~000.0~M00.0fZwo.63~-f.zU~~~.~~~~~.~~~~~.~~~~~.~~~~~.V-vD~.
pStD~.M000f.Y0003.~0000.~M000.fZ6hA.r~GqC.F~X-~.L~Z7h.Qv~82.0w~~b.OYL~~.
~~~~~.~~~~~.~~~~~.~~~~~.~~~~~.~X-~L.-FGqD.~nlRt.~SRJr.v~3MY.f~~~~.~~~~~.
~~~~~.~~~Xu.TJ~Yv.7N~~~]
::
[98 (fil 6 98 0w3.~~~~~)]
[1 0wf~~]
[63 (fil 6 63 0w0)]
[11 0wf~~0.00000.00000.00000.00000.00050.00000.00200.0g000.40000.0w000.0a000]
[389 (fil 6 389 0w3.~~~~~)]
[3 0w~.~~~Xe.PI~~H.W-L~~]
[9 (fil 6 9 0w3.~~~~~)]
[6 0w~~.~~StD.p~VWu.DL-7x.Uv~Dp.St~Zv.nR~~~]
[14 (fil 6 14 0w3.~~~~~)]
[4 0w3~.~~~IX.eP~ez.EW~WG.GGL~~]
[5 (fil 6 5 0w3.~~~~~)]
[11 0wf~~~.-byUL.ZzoSf.~3MYf.~M000.fY000.
3~000.0~MQd.3vZik.Bb~Kb.yU~~P.Y~f~~]
[11 (fil 6 11 0w3.~~~~~)]
[13 0wfY.10g7~.gk51~.WOIHf.~RZvn.~~~~~.~~~~~.
~~~~~.~~W-L.H~QVe.jLY00.03~cj.4N~~b.OYL~~]
[6 (fil 6 6 0wfY0)]
[3 0w~.~~~Os.D9~Ok.B9vY0]
[10 (fil 6 10 0w3.~~~~~)]
[10 0wf.YJbiT.~sTdP.~VunB.~ZZvn.T~aiA.F~M00.0fY00.03~00.00~VG.qCL~~]
[10 (fil 6 10 0wfY0)]
[3 0w~.~~~Qt.7h~NI.r6~Y0]
[9 (fil 6 9 0w3.~~~~~)]
[3 0w3~5N.sn~Y~.fP~~~]
[10 (fil 6 10 0wfY0)]
[10 0w3~~~.-QJbj.~0000.~M000.fY000.3~6hA.p~SFG.qL-6x.Er~oC.9y~NU.u7LY0]
[10 (fil 6 10 0w3.~~~~~)]
[3 0w3~5h.kl~XG.WKL~~]
[7 (fil 6 7 0wfY0)]
[12 0w~~~~.~fPY~.QB9iv.Y0003.~k51g.~Z~vT.~~~~~.
~~~~~.~~~~~.~~~FW.uD~Cp.Cp~P8.OcLY0]
[11 (fil 6 11 0w3.~~~~~)]
[11 0wf~~~.~nRZv.-FGqD.~hQt7.~MEa2.LY000.
3~000.0~M00.0fY20.wb~i4.x8~YX.ePL~~]
[5 (fil 6 5 0w3.~~~~~)]
[4 0w3~.~~-~L.X~~lB.pm~~n.RZv~~]
[13 (fil 6 13 0w3.~~~~~)]
[7 0w3~~.~~kRd.j~DFW.u~Ue3.w~-ez.EX~Nc.j4~~P.Y~f~~]
[9 (fil 6 9 0w3.~~~~~)]
[3 0w~.~~~~L.X-~~H.W-L~~]
[389 (fil 6 389 0w3.~~~~~)]
[1 0wf~~]
==
::
2015-02-11 22:26:42 +03:00
++ js :: static javascript
|%
2015-05-30 02:47:38 +03:00
++ poll :: dependency long-poll
2015-02-11 22:26:42 +03:00
'''
2015-02-14 06:43:17 +03:00
urb.tries = 0
2015-02-11 22:26:42 +03:00
urb.call = function() {
2015-05-02 00:43:41 +03:00
urb.wreq = new XMLHttpRequest()
urb.wreq.open('GET', "/~/on.json?"+urb.deps.join('&'), true)
2015-05-02 00:43:41 +03:00
urb.wreq.addEventListener('load', function() {
2015-02-17 02:19:58 +03:00
// if(~~(this.status / 100) == 4)
2015-05-02 00:43:41 +03:00
// return document.write(this.responseText)
if(this.status === 200) {
var dep = JSON.parse(this.responseText)
urb.onupdate(dep)
urb.dewasp(dep)
2015-02-11 22:26:42 +03:00
}
urb.keep()
2015-02-14 06:43:17 +03:00
})
2015-05-02 00:43:41 +03:00
urb.wreq.addEventListener('error', urb.keep)
urb.wreq.addEventListener('abort', urb.keep)
urb.wreq.send()
2015-02-11 22:26:42 +03:00
}
urb.keep = function() {
2015-02-14 06:43:17 +03:00
setTimeout(urb.call,1000*urb.tries)
urb.tries++
2015-02-11 22:26:42 +03:00
}
2015-09-11 22:20:19 +03:00
urb.onupdate = function(){document.location.reload()}
2015-02-14 06:43:17 +03:00
urb.call()
2015-05-02 00:43:41 +03:00
urb.wasp = function(deh){
if (!deh) return;
if (urb.deps.indexOf(deh) !== -1) return;
urb.deps.push(deh)
urb.wreq.abort() // trigger keep
2015-05-02 00:43:41 +03:00
}
urb.dewasp = function(deh){
var index = urb.deps.indexOf(deh)
if (-1 !== index) {
urb.deps.splice(index,1)
urb.wreq.abort() // trigger keep
}
}
2015-02-11 22:26:42 +03:00
'''
2015-03-03 04:52:55 +03:00
::
2015-03-27 04:19:08 +03:00
++ auth-redir
'document.location.pathname = "/~~"+document.location.pathname'
::
2015-03-03 04:52:55 +03:00
++ auth
'''
2015-03-09 23:55:54 +03:00
var req = function(url,dat,cb){
var xhr = new XMLHttpRequest()
xhr.open('POST', url, true)
dat.oryx = urb.oryx
xhr.send(JSON.stringify(dat))
xhr.addEventListener('load', function(ev){
if(this.status !== 200)
2015-03-12 02:51:04 +03:00
return err.innerHTML = ":( " + Date.now() + "\n" + xhr.responseText
2015-03-09 23:55:54 +03:00
else if(cb) return cb(xhr.responseText,ev)
})
}
2015-03-09 23:06:00 +03:00
urb.foreign = /^\/~\/am/.test(window.location.pathname)
2015-05-19 03:59:40 +03:00
urb.redir = function(ship){
if(ship) document.location.pathname =
document.location.pathname.replace(/^\/~~|\/~\/as\/any/,'/~/as/~'+ship)
2015-05-19 03:59:40 +03:00
else document.location =
document.location.hash.match(/#[^?]+/)[0].slice(1) +
document.location.pathname.replace(
/^\/~\/am\/[^/]+/,
'/~/as/~' + urb.ship) +
document.location.search
}
if(urb.foreign && urb.auth.indexOf(urb.ship) !== -1){
req("/~/auth.json?PUT",
{ship:urb.ship,code:null},
2015-05-19 03:59:40 +03:00
function(){urb.redir()})
}
urb.is_me = function(ship) {
return (urb.ship === ship)
}
urb.submit = function(ship,pass){
if(!urb.is_me(ship))
return urb.redir(ship)
2015-03-09 23:55:54 +03:00
req(
"/~/auth.json?PUT",
{ship:ship, code:pass},
2015-03-09 23:55:54 +03:00
function(){
2015-05-19 21:36:34 +03:00
if(urb.foreign) urb.redir()
2015-03-09 23:06:00 +03:00
else document.location.reload()
2015-03-09 23:55:54 +03:00
})
2015-03-03 04:52:55 +03:00
}
2015-03-09 23:55:54 +03:00
urb.away = function(){req("/~/auth.json?DELETE", {},
function(){document.getElementById("c").innerHTML = "" }
2015-03-13 03:37:52 +03:00
)}
2015-03-03 04:52:55 +03:00
'''
--
++ xml
|%
++ login-page
%+ titl 'Sign in - Urbit'
;= ;div.container
;div.row
2016-02-04 22:52:00 +03:00
;div.col-md-4
;h1.sign: Sign in
==
;div.col-md-8
;p.ship
;label.sig: ~
;input#ship.mono(contenteditable "", placeholder "planet");
==
;input#pass.mono(type "password", placeholder "passcode");
;h2.advice: Your passcode code has been printed to your console.
;pre:code#err;
==
==
==
;script@"/~/at/~/auth.js";
;script:'''
$(function() {
$ship = $('#ship')
$pass = $('#pass')
$ship.on('keydown', function(e) {
if(e.keyCode === 13 || e.keyCode === 9) {
if(!urb.is_me($ship.val().toLowerCase()))
urb.redir($ship.val().toLowerCase())
$pass.show()
$pass.focus()
e.preventDefault()
}
})
$ship.on('focus', function(e) {
$pass.hide()
})
$pass.on('keydown', function(e) {
if(e.keyCode === 13) {
urb.submit($ship.val().toLowerCase(),$pass.val())
}
})
if(window.ship) {
$ship.val(urb.ship)
$pass.focus()
} else {
$pass.hide()
}
})
'''
2015-03-03 04:52:55 +03:00
==
2015-03-09 23:55:54 +03:00
::
++ logout-page
2015-03-13 03:37:52 +03:00
%+ titl 'Log out'
;= ;div.container
;div.row
;div.col-md-4
;h1.sign: Bye!
==
;div.col-md-8#c
;p.ship
;label.sig: ~
;span#ship;
==
;button#act(onclick "urb.away()"): Go
;pre:code#err;
;script@"/~/at/~/auth.js";
==
==
==
==
2015-03-13 03:37:52 +03:00
::
++ poke-test
%+ titl 'Poke'
;= ;button(onclick "urb.testPoke('/~/to/hood/helm-hi.json')"): Hi anonymous
;button(onclick "urb.testPoke('/~/as/own/~/to/hood/helm-hi.json')"): Hi
2015-03-13 03:37:52 +03:00
;pre:code#err;
;script@"/~/at/~/auth.js";
;script:'''
2015-03-18 00:38:13 +03:00
show = function(t){err.innerText = ":) " + Date.now() + "\n" + t}
2015-03-13 03:37:52 +03:00
urb.testPoke = function(url){
req(url,{wire:"/",xyro:'test'}, show)
2015-03-13 03:37:52 +03:00
}
'''
==
2015-05-15 22:36:56 +03:00
++ titl
2015-12-20 23:50:45 +03:00
|= {a/cord b/marl}
2015-05-15 22:36:56 +03:00
;html
;head
;meta(charset "utf-8");
;meta(name "viewport", content "width=device-width, ".
"height=device-height, initial-scale=1.0, user-scalable=0, ".
"minimum-scale=1.0, maximum-scale=1.0");
2015-05-15 22:36:56 +03:00
;title:"{(trip a)}"
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/".
"libs/jquery/2.1.1/jquery.min.js");
;link(rel "stylesheet", href "/lib/css/fonts.css");
;link(rel "stylesheet", href "/lib/css/bootstrap.css");
2015-05-15 22:36:56 +03:00
==
;body:div#c:"*{b}"
==
2015-02-11 22:26:42 +03:00
--
2013-09-29 00:21:18 +04:00
--
2014-03-12 23:50:39 +04:00
|% :: functions
++ ye :: per event
2015-12-20 23:50:45 +03:00
=| $: $: hen/duct :: event floor
$: now/@da :: event date
eny/@ :: unique entropy
our/ship :: current ship
2016-02-04 10:12:23 +03:00
sky/$-({* *} (unit)) :: system namespace
== ::
2015-12-20 23:50:45 +03:00
mow/(list move) :: pending actions
2014-03-12 23:50:39 +04:00
== ::
bolo :: all vane state
== ::
=* bol ->
|%
2015-02-27 03:04:12 +03:00
++ abet :: resolve moves
2015-12-06 07:50:40 +03:00
^- {(list move) bolo}
2014-03-12 23:50:39 +04:00
[(flop mow) bol]
2013-09-29 00:21:18 +04:00
::
2015-02-27 03:04:12 +03:00
++ adit .(ney (mix eny ney)) :: flip entropy
2014-06-04 14:40:09 +04:00
::
2015-03-03 04:52:55 +03:00
++ anon `@p`(add our ^~((bex 64))) :: pseudo-sub
2015-02-27 03:04:12 +03:00
++ apex :: accept request
2015-12-20 23:50:45 +03:00
|= kyz/kiss
2014-06-04 14:40:09 +04:00
^+ +>
2015-03-09 23:06:00 +03:00
=. our ?~(hov our u.hov) :: XX
=. p.top our :: XX necessary?
2014-06-04 14:40:09 +04:00
?- -.kyz
2015-12-06 23:54:14 +03:00
$born +>.$(ged hen) :: register external
$serv
=< ~&([%serving (tope top)] .)
?^(p.kyz +>.$(top p.kyz) +>.$(q.top p.kyz))
::
2015-12-06 23:54:14 +03:00
$crud
+>.$(mow [[hen %slip %d %flog kyz] mow])
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
$init :: register ownership
=. our ?~(hov p.kyz (min u.hov p.kyz))
+>.$(hov [~ our], top [[our %home ud+0] /web])
2015-02-18 00:05:28 +03:00
::
2015-12-06 23:54:14 +03:00
$this :: inbound request
2015-03-28 04:06:38 +03:00
%- emule |. ^+ ..apex
2014-06-04 14:40:09 +04:00
=* sec p.kyz :: ? :: https bit
=* heq r.kyz :: httq :: request content
2014-03-12 23:50:39 +04:00
=+ ryp=`quri`(rash q.heq zest:epur)
2015-03-28 04:06:38 +03:00
=+ maf=(eat-headers r.heq)
2014-03-12 23:50:39 +04:00
=+ ^= pul ^- purl
?- -.ryp
$& ?>(=(sec p.p.p.ryp) p.ryp)
$| =+ hot=(~(get ja maf) %host)
?> ?=({@ $~} hot)
[[sec (rash i.hot thor:epur)] p.ryp q.ryp]
2014-03-12 23:50:39 +04:00
==
2015-01-15 04:47:51 +03:00
=. p.p.pul |(p.p.pul ?=(hoke r.p.pul))
2015-03-23 22:35:25 +03:00
=+ her=(host-to-ship r.p.pul)
?: |(?=($~ her) =(our u.her))
(handle pul [q.+.kyz |] [p.heq maf s.heq])
2015-03-23 22:35:25 +03:00
=+ han=(sham hen)
=. pox (~(put by pox) han hen)
(ames-gram u.her [%get ~] han +.kyz)
2014-03-12 23:50:39 +04:00
::
2015-12-06 23:54:14 +03:00
$them :: outbound request
2014-06-04 14:40:09 +04:00
?~ p.kyz
2014-03-12 23:50:39 +04:00
=+ sud=(need (~(get by kes) hen))
2014-06-04 14:40:09 +04:00
%= +>.$
2014-05-24 00:46:43 +04:00
mow :_(mow [ged [%give %thus sud ~]])
2014-03-12 23:50:39 +04:00
q.ask (~(del by q.ask) sud)
kes (~(del by kes) hen)
==
2015-12-21 00:16:39 +03:00
:: ~& eyre-them+(earn p.u.p.kyz)
2014-06-04 14:40:09 +04:00
%= +>.$
mow :_(mow [ged [%give %thus p.ask p.kyz]])
2014-03-12 23:50:39 +04:00
p.ask +(p.ask)
2014-06-04 14:40:09 +04:00
q.ask (~(put by q.ask) p.ask hen u.p.kyz)
2014-03-12 23:50:39 +04:00
kes (~(put by kes) hen p.ask)
==
2015-05-28 01:34:01 +03:00
::
2015-12-06 23:54:14 +03:00
$hiss :: outbound cage
2015-05-28 01:34:01 +03:00
::?~ p.kyz :: XX cancel
:: =+ sud=(need (~(get by kes) hen))
:: %= +>.$
:: mow :_(mow [ged [%give %thus sud ~]])
:: q.ask (~(del by q.ask) sud)
:: kes (~(del by kes) hen)
:: ==
2015-12-21 00:16:39 +03:00
:: ~& eyre-them+(earn p.u.p.kyz)
=+ wir=hi+/[p.kyz]
2015-12-06 23:54:14 +03:00
?: ?=($hiss p.q.kyz)
(pass-note wir [%e %meta :(slop !>(%them) !>(~) q.q.kyz)])
(back wir %hiss q.kyz)
2014-03-12 23:50:39 +04:00
::
2015-12-06 23:54:14 +03:00
$they :: inbound response
2014-06-04 14:40:09 +04:00
=+ kas=(need (~(get by q.ask) p.kyz))
2015-12-21 00:16:39 +03:00
:: ~& > eyre-they+[p.q.kyz (earn p.q.kas)]
2014-06-04 14:40:09 +04:00
%= +>.$
mow :_(mow [p.kas [%give %thou q.kyz]])
2014-03-12 23:50:39 +04:00
q.ask (~(del by q.ask) p.kas)
==
::
2015-12-06 23:54:14 +03:00
$thud :: cancel request
2015-12-01 05:02:41 +03:00
?. (~(has by lyv) hen)
2015-12-21 00:16:39 +03:00
~& dead-request+hen
2015-12-01 05:02:41 +03:00
+>.$(ded (~(put in ded) hen)) :: uncaught requests
=+ lid=(~(got by lyv) hen)
2015-12-21 00:16:39 +03:00
:: ~& did-thud+[-.lid hen]
2015-12-01 05:02:41 +03:00
?- -.lid
2015-12-06 23:54:14 +03:00
$exec
2015-12-02 01:38:18 +03:00
(pass-note p.lid %f [%exec our ~])
2015-12-01 05:02:41 +03:00
::
2015-12-06 23:54:14 +03:00
$poll
2015-12-02 01:38:18 +03:00
?. (~(has by wix) p.lid)
+>.$
poll-dead:(ire-ix p.lid)
::
2015-12-06 23:54:14 +03:00
$xeno
2015-12-02 01:38:18 +03:00
=+ han=(sham hen)
=. pox (~(del by pox) han hen)
(ames-gram p.lid [%gib ~] han)
::
2015-12-06 23:54:14 +03:00
$wasp
2015-12-02 01:38:18 +03:00
|- ^+ +>.^$
?~ p.lid +>.^$
(del-deps:$(p.lid t.p.lid) i.p.lid %& hen)
2015-12-01 05:02:41 +03:00
==
2014-03-23 01:42:25 +04:00
::
2015-12-06 23:54:14 +03:00
$west :: remote request
2015-06-23 01:56:57 +03:00
=. mow :_(mow [hen %give %mack ~])
=+ mez=((soft gram) q.kyz)
2015-02-20 02:33:39 +03:00
?~ mez
2015-12-21 00:16:39 +03:00
~& e+[%strange-west p.kyz]
2015-06-23 01:56:57 +03:00
~|(%strange-west !!)
2015-03-09 23:06:00 +03:00
?- -<.u.mez
2015-12-06 23:54:14 +03:00
$aut abet:(logon:(ses-ya p.u.mez) q.p.kyz)
$hat (foreign-hat:(ses-ya p.u.mez) q.p.kyz q.u.mez)
2015-12-21 00:16:39 +03:00
$gib (pass-note ay+(dray p+uv+~ q.p.kyz p.u.mez) [%e %thud ~])
$get (pass-note ay+(dray p+uv+~ q.p.kyz p.u.mez) [%e %this q.u.mez])
2015-12-06 23:54:14 +03:00
$got
2015-05-19 21:26:45 +03:00
?. (~(has by pox) p.u.mez)
2015-12-21 00:16:39 +03:00
~& lost-gram-thou+p.kyz^p.u.mez
2015-05-19 21:26:45 +03:00
+>.$
=: hen (~(got by pox) p.u.mez)
pox (~(del by pox) p.u.mez)
==
(give-thou q.u.mez)
2014-03-23 01:42:25 +04:00
::
2015-12-06 23:54:14 +03:00
$lon
2015-12-21 00:16:39 +03:00
~& ses-ask+[p.u.mez sop (~(run by wup) $~)]
2015-03-09 23:06:00 +03:00
?: (ses-authed p.u.mez)
2015-12-21 00:16:39 +03:00
(ames-gram q.p.kyz aut+~ p.u.mez)
2015-03-09 23:06:00 +03:00
=. sop (~(put by sop) p.u.mez q.p.kyz |)
2015-12-21 00:16:39 +03:00
(ames-gram q.p.kyz hat+~ p.u.mez our-host)
2014-03-23 01:42:25 +04:00
==
2015-05-07 05:25:41 +03:00
::
2015-12-06 23:54:14 +03:00
$wegh !! :: handled elsewhere
2014-03-12 23:50:39 +04:00
==
2013-09-29 00:21:18 +04:00
::
2015-12-02 01:38:18 +03:00
::++ axom :: old response
:: |= [tee=whir hon=honk]
:: ^+ +>
:: ?+ tee !!
:: ~ ?-(-.hon %nice (nice-json), %mean (mean-json 500 p.hon))
:: [%of @ ^] (get-ack:(ire-ix p.tee) q.tee hon)
:: ==
2015-03-28 04:06:38 +03:00
++ axon :: accept response
2015-12-26 13:07:50 +03:00
|= {tee/whir typ/span sih/sign}
2014-04-09 02:26:01 +04:00
^+ +>
2015-03-28 04:06:38 +03:00
=. our ?~(hov our u.hov) :: XX
2015-12-06 23:54:14 +03:00
?: &(?=({?($of $ow) ^} tee) !(~(has by wix) p.tee))
2015-12-21 00:16:39 +03:00
~&(dead-ire+[`whir`tee ({term term $~} +.sih)] +>)
2015-03-28 04:06:38 +03:00
?- &2.sih
2015-12-06 23:54:14 +03:00
$crud +>.$(mow [[hen %slip %d %flog +.sih] mow])
:: $dumb
2015-05-10 01:55:05 +03:00
:: =. +> ?+(tee +> [%of ^] pop-duct:(ire-ix p.tee))
2015-12-21 00:16:39 +03:00
:: (emule |.(~|(gall-dumb+tee !!)))
2015-04-07 23:31:09 +03:00
::
2015-12-06 23:54:14 +03:00
$woot +>.$
$thou
2015-05-28 01:34:01 +03:00
?+ -.tee !!
2015-12-21 00:16:39 +03:00
$ay (ames-gram (slav %p p.tee) got+~ (slav %uv q.tee) |2.sih)
2015-12-06 23:54:14 +03:00
$hi =+ cay=[%httr !>(`httr`p.sih)]
?: ?=($httr p.tee) (give-sigh %& cay)
2015-12-21 00:16:39 +03:00
(back si+~ p.tee cay)
2015-05-28 01:34:01 +03:00
==
2015-05-08 23:27:40 +03:00
::
2015-12-06 23:54:14 +03:00
$unto :: app response
?> ?=({$of @ ^} tee)
2015-05-08 23:27:40 +03:00
=+ cuf=`cuft`+>.sih
?- -.cuf
?($coup $reap)
2015-12-02 01:38:18 +03:00
(get-ack:(ire-ix p.tee) q.tee ?~(p.cuf ~ `[-.cuf u.p.cuf]))
2015-05-08 23:27:40 +03:00
::
2015-12-06 23:54:14 +03:00
$doff !!
$diff
?. ?=($json p.p.cuf)
2015-12-02 01:38:18 +03:00
:: ~> %slog.`%*(. >[%backing p.p.cuf %q-p-cuf]< &3.+> (sell q.p.cuf))
(back tee %json p.cuf)
2015-05-10 01:55:05 +03:00
(get-rush:(ire-ix p.tee) q.tee ((hard json) q.q.p.cuf))
2015-05-08 23:27:40 +03:00
::
2015-12-21 00:16:39 +03:00
$quit ~&(quit+tee (get-quit:(ire-ix p.tee) q.tee))
2015-03-28 04:06:38 +03:00
==
::
2015-12-06 23:54:14 +03:00
$wake
?> ?=({?($of $ow) @ $~} tee)
?: ?=($ow -.tee)
2015-12-02 01:38:18 +03:00
abut:(ire-ix p.tee)
2015-03-28 04:06:38 +03:00
=> wake:(ire-ix p.tee)
(give-json 200 ~ (joba %beat %b &))
::
2015-12-06 23:54:14 +03:00
$news :: dependency updated
?. ?=({$on $~} tee)
2015-12-21 00:16:39 +03:00
~&(e+lost+[tee hen] +>.$)
2015-07-10 23:38:12 +03:00
%+ roll (~(tap in (~(get ju liz) p.sih)))
=< .(con ..axon(liz (~(del by liz) p.sih)))
2015-12-20 23:50:45 +03:00
|= {sus/(each duct ixor) con/_..axon}
2015-03-28 04:06:38 +03:00
=. ..axon con
?- -.sus
$& (give-json(hen p.sus) 200 ~ %s (scot %uv p.sih))
$| (get-even:(ire-ix p.sus) +.sih)
2015-03-28 04:06:38 +03:00
==
::
2015-12-06 23:54:14 +03:00
$made
?< ?=($tabl -.q.sih)
2015-03-28 04:06:38 +03:00
=. our (need hov) :: XX
|- ^+ ..axon
?- tee
$@($~ {?($on $ay $ow) *}) ~|(e+ford+lost+tee !!)
2015-12-21 00:16:39 +03:00
{$of @ $~} ~|(e+ford+lost+tee !!)
{$si $~} (give-sigh q.sih)
2015-12-08 03:56:51 +03:00
::
2015-12-06 23:54:14 +03:00
{$hi ^}
?: ?=($| -.q.sih)
2015-05-28 01:34:01 +03:00
(give-sigh q.sih) :: XX crash?
=* cay p.q.sih
?> ?=($hiss p.cay)
2015-05-28 01:34:01 +03:00
(pass-note tee [%e %meta :(slop !>(%them) !>(~) q.cay)])
2015-12-08 03:56:51 +03:00
::
2015-12-06 23:54:14 +03:00
{$he *} :: XX hack
2015-05-06 00:24:48 +03:00
=. ..axon $(tee p.tee)
%_ ..axon
mow %+ turn mow
2015-12-20 23:50:45 +03:00
|= a/move
2015-05-06 00:24:48 +03:00
?+ q.a a
2015-12-06 23:54:14 +03:00
{$give $thou *} a(r.p.p.q ~)
{$pass ^} ?.(=(p.tee p.q.a) a a(p.q tee))
2015-05-06 00:24:48 +03:00
== ==
::
2015-12-06 23:54:14 +03:00
{$of @ ^}
?: ?=($| -.q.sih)
2015-07-28 01:39:36 +03:00
((slog p.q.sih) +>.^$) :: XX get-even %mean
2015-04-07 02:36:07 +03:00
%+ get-rush:(ire-ix p.tee) q.tee
?> ?=($json p.p.q.sih) :: XX others
((hard json) q.q.p.q.sih)
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
{$at ^}
2016-02-12 22:46:39 +03:00
?: ?=($| -.q.sih) $(tee q.tee)
?. ?=($js -.p.q.sih)
~& e+at-lost+[-.p.q.sih q.tee]
2015-03-28 04:06:38 +03:00
$(tee q.tee)
?> ?=(@ q.q.p.q.sih)
2015-03-28 04:06:38 +03:00
=+ cyz=(~(got by wup) p.tee)
=^ jon ..ya ~(stat-json ya p.tee cyz)
$(tee q.tee, q.q.p.q.sih (add-json jon q.q.p.q.sih))
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
{$ha *}
2015-08-19 20:40:01 +03:00
%- emule |. ^+ ..apex
2015-12-06 23:54:14 +03:00
?. ?=($& -.q.sih)
2015-03-28 04:06:38 +03:00
(fail 404 p.sih p.q.sih)
=* cay p.q.sih
?: ?=($red-quri p.cay)
=+ url=((hard quri) q.q.cay)
(give-thou 307 [location+(crip (apex:earn url))]~ ~)
?. ?=($mime p.cay)
=+ bek=-:(need (tome p.tee))
2015-12-21 00:16:39 +03:00
=+ bik=?+(r.bek bek {$ud $0} bek(r da+now))
(execute tee bik [%flag [p.sih `~] %cast %mime [%$ p.q.sih]])
2015-03-28 04:06:38 +03:00
~| q.q.cay
=+ ((hard {mit/mite rez/octs}) q.q.cay)
2015-09-23 23:50:31 +03:00
=+ dep=(crip "W/{(pojo %s (scot %uv p.sih))}")
2015-12-21 00:16:39 +03:00
(give-thou 200 ~[etag+dep content-type+(moon mit)] ~ rez)
2015-03-28 04:06:38 +03:00
==
==
2014-03-23 01:42:25 +04:00
::
2015-03-28 04:06:38 +03:00
++ emule
2015-12-20 23:50:45 +03:00
|= a/_|?(..emule) ^+ ..emule
2015-03-28 04:06:38 +03:00
=+ mul=(mule a)
?~ -.mul p.mul
(fail 500 0v0 >%exit< p.mul)
::
2015-12-20 23:50:45 +03:00
++ ire-ix |=(ire/ixor ~(. ix ire (~(got by wix) ire)))
2013-09-29 00:21:18 +04:00
::
2015-03-09 23:06:00 +03:00
++ ses-authed
2015-12-20 23:50:45 +03:00
|= ses/hole
2015-03-09 23:06:00 +03:00
=+ sap=(~(get by sop) ses)
2015-12-06 23:54:14 +03:00
?: ?=({$~ @ $&} sap) &
2015-03-09 23:06:00 +03:00
=+ cyz=(~(get by wup) ses)
?~ cyz |
(~(has in aut.u.cyz) our)
::
2015-12-20 23:50:45 +03:00
++ ses-ya |=(ses/hole ~(. ya ses (~(got by wup) ses)))
2015-12-29 01:01:44 +03:00
++ our-host `hart`[& ~ %& /org/urbit/(rsh 3 1 (scot %p our))]
:: [| [~ 8.443] `/localhost] :: XX testing
2014-04-09 02:26:01 +04:00
::
2015-03-28 04:06:38 +03:00
++ ames-gram
2015-12-20 23:50:45 +03:00
|=({him/ship gam/gram} (pass-note ~ %a %wont [our him] [%e -.gam] +.gam))
2014-05-16 04:46:48 +04:00
::
2015-03-28 04:06:38 +03:00
++ back :: %ford bounce
2015-12-20 23:50:45 +03:00
|= {tea/whir mar/mark cay/cage}
=+ bek=?+(r.top -.top {$ud $0} -.top(r da+now))
(pass-note tea (ford-req bek [%cast mar $+cay]))
2014-10-23 07:13:10 +04:00
::
2015-12-01 05:02:41 +03:00
++ del-deps
2015-12-20 23:50:45 +03:00
|= {a/@uvH b/(each duct ixor)} ^+ +>.$
2016-01-25 06:37:41 +03:00
?: =(`@`0 a) +>.$
2015-12-01 05:02:41 +03:00
=. liz (~(del ju liz) a b)
2015-12-21 00:16:39 +03:00
:: ~& del-deps+[a (~(get ju liz) a)]
2015-12-01 05:02:41 +03:00
?: (~(has by liz) a) +>.$
=- -(hen hen.+)
2015-12-21 00:16:39 +03:00
(pass-note(hen `~) on+~ %f [%wasp our a |])
2015-12-01 05:02:41 +03:00
::
++ new-deps
2015-12-20 23:50:45 +03:00
|= {a/@uvH b/(each duct ixor)} ^+ +>.$
2015-12-21 00:16:39 +03:00
:: ~& new-deps+[a b]
2016-01-25 06:37:41 +03:00
?: =(`@`0 a) +>.$
2015-12-01 05:02:41 +03:00
=+ had=(~(has by liz) a)
=. liz (~(put ju liz) a b)
?: had +>.$
=- -(hen hen.+)
2015-12-21 00:16:39 +03:00
(pass-note(hen `~) on+~ %f [%wasp our a &])
2015-12-01 05:02:41 +03:00
::
2015-12-20 23:50:45 +03:00
++ ford-req |=({bek/beak kas/silk} [%f [%exec our `[bek kas]]])
2015-12-01 05:02:41 +03:00
++ execute
2015-12-20 23:50:45 +03:00
|= {tea/whir req/{beak silk}}
2015-12-01 05:02:41 +03:00
=. lyv (~(put by lyv) hen [%exec tea])
(pass-note tea (ford-req req))
::
2015-03-28 04:06:38 +03:00
++ fail
2015-12-20 23:50:45 +03:00
|= {sas/@ud dep/@uvH mez/tang}
^+ +>
2015-12-21 00:16:39 +03:00
:: (back ha+~ dep %tang !>(mez)) ::tang->urb chain may be source of failure
(give-html sas ~ (render-tang dep mez))
::
2015-03-28 04:06:38 +03:00
++ give-html
2015-12-20 23:50:45 +03:00
|= {sas/@ud cug/(list @t) max/manx}
2015-03-28 04:06:38 +03:00
%- give-thou
2015-03-09 23:06:00 +03:00
%+ add-cookies cug
2015-12-21 00:16:39 +03:00
(resp sas text+/html (crip (poxo max)))
2014-03-12 23:50:39 +04:00
::
2015-03-28 04:06:38 +03:00
++ give-json
2015-12-20 23:50:45 +03:00
|= {sas/@uG cug/(list @t) jon/json}
2015-03-28 04:06:38 +03:00
%- give-thou
2015-03-09 23:06:00 +03:00
%+ add-cookies cug
2015-12-21 00:16:39 +03:00
(resp sas application+/json (crip (pojo jon)))
2013-09-29 00:21:18 +04:00
::
2015-03-28 04:06:38 +03:00
++ give-thou :: done request
2015-12-20 23:50:45 +03:00
|= hit/httr
2015-04-15 00:16:46 +03:00
?: (~(has in ded) hen) :: request closed
+>(ded (~(del in ded) hen))
2015-12-01 05:02:41 +03:00
=. lyv (~(del by lyv) hen)
2015-03-28 04:06:38 +03:00
+>(mow :_(mow [hen %give %thou hit]))
::
2015-05-28 01:34:01 +03:00
++ give-sigh :: userspace done
2015-12-20 23:50:45 +03:00
|= res/(each cage tang)
2015-05-28 01:34:01 +03:00
=- +>.$(mow :_(mow [hen %give %sigh `cage`-]))
2015-12-06 23:54:14 +03:00
?. ?=($| -.res) p.res
2015-05-28 01:34:01 +03:00
[%tang !>(p.res)]
::
2015-12-20 23:50:45 +03:00
++ mean-json |=({sas/@uG err/ares} (give-json sas ~ (ares-to-json err)))
2015-03-28 04:06:38 +03:00
++ nice-json |=(* (give-json 200 ~ (joba %ok %b &)))
::
2015-12-20 23:50:45 +03:00
++ pass-note |=(noe/{whir note} +>(mow :_(mow [hen %pass noe])))
2015-03-03 04:52:55 +03:00
++ host-to-ship :: host to ship
2015-12-20 23:50:45 +03:00
|= hot/host
2014-03-12 23:50:39 +04:00
^- (unit ship)
2015-05-16 02:21:09 +03:00
:: =+ gow=(~(get by dop) hot) :: XX trust
:: ?^ gow gow
2015-12-06 23:54:14 +03:00
?. ?=($& -.hot) ~
2015-02-27 03:04:12 +03:00
=+ dom=(flop p.hot) :: domain name
?~ dom ~
(rush i.dom fed:ag)
2014-10-23 07:13:10 +04:00
::
2015-03-28 04:06:38 +03:00
++ load-secret
^- @ta
=+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our)
%^ rsh 3 1
(scot %p (@ (need (sky [151 %noun] %a pax))))
2014-10-23 07:13:10 +04:00
::
::
2015-03-28 04:06:38 +03:00
++ handle
2015-12-20 23:50:45 +03:00
|= $: {hat/hart pok/pork quy/quay} :: purl parsed url
{cip/clip aut/?} :: client ip nonymous?
2015-12-21 00:16:39 +03:00
{mef/meth maf/math bod/(unit octs)} :: method+headers+body
2015-02-27 03:04:12 +03:00
==
2015-03-28 04:06:38 +03:00
=< apex
2014-03-12 23:50:39 +04:00
|%
2015-03-28 04:06:38 +03:00
++ abet ..handle
2015-03-03 04:52:55 +03:00
++ done .
2016-02-04 10:12:23 +03:00
++ teba |*(a/$-(* ..handle) |*(b/* %_(done ..handle (a b))))
2015-12-01 05:02:41 +03:00
++ execute (teba ^execute)
++ del-deps (teba ^del-deps)
++ new-deps (teba ^new-deps)
2015-03-03 04:52:55 +03:00
++ give-html (teba ^give-html)
2015-03-28 04:06:38 +03:00
++ give-thou (teba ^give-thou)
2015-03-03 04:52:55 +03:00
++ give-json (teba ^give-json)
2015-03-12 02:51:04 +03:00
++ nice-json (teba ^nice-json)
2015-03-03 04:52:55 +03:00
++ pass-note (teba ^pass-note)
::
++ fcgi-cred
^- cred
?: aut fcgi-cred:for-client
%*(fcgi-cred for-client him anon)
2014-06-08 06:45:00 +04:00
::
++ apex
2015-03-28 04:06:38 +03:00
=< abet
2015-03-03 04:52:55 +03:00
^+ done
2015-03-09 23:06:00 +03:00
=+ oar=(host-to-ship r.hat)
=. our ?~(oar our u.oar) :: XX
2015-03-04 05:22:02 +03:00
=+ pez=process
2015-12-06 23:54:14 +03:00
?: ?=($| -.pez) p.pez
2015-04-02 08:41:39 +03:00
(resolve ~ p.pez)
2014-07-11 06:40:58 +04:00
::
2015-03-28 04:06:38 +03:00
++ resolve
2015-12-20 23:50:45 +03:00
|= {cug/(list @t) pez/pest} ^+ done
2015-04-02 08:41:39 +03:00
?~ pez done
2015-03-19 03:22:20 +03:00
?- -.pez
2016-02-01 09:16:26 +03:00
$~ (give-thou (add-cookies cug p.pez))
$js $(pez [%$ (resp 200 text+/javascript p.pez)])
2015-12-06 23:54:14 +03:00
$json (give-json 200 cug p.pez)
$html (give-html 200 cug p.pez)
$htme (give-html 401 cug p.pez)
$bake
=+ req=[%bake mar=q.pez [r s]:pez]
=+ red=req(mar %red-quri)
(execute p.pez -.s.pez `silk`[%alts ~[red req]])
2015-12-08 03:56:51 +03:00
::
2015-12-06 23:54:14 +03:00
$red
2015-03-13 03:17:00 +03:00
=+ url=(earn hat pok(p [~ %html]) quy)
2015-12-21 00:16:39 +03:00
?+ p.pok ~|(bad-redirect+[p.pok url] !!)
2015-12-06 23:54:14 +03:00
{$~ $js}
2015-04-02 08:41:39 +03:00
$(pez [%js auth-redir:js])
2015-12-06 23:54:14 +03:00
{$~ $json}
2015-12-21 00:16:39 +03:00
$(pez [%json (jobe ok+b+| red+(jape url) ~)])
2015-03-13 03:17:00 +03:00
==
2014-06-10 00:09:14 +04:00
==
::
::
++ is-anon =([~ ''] (~(get by (molt quy)) 'anon'))
2015-03-03 04:52:55 +03:00
++ check-oryx :: | if json with bad oryx
^- ?
2015-12-06 23:54:14 +03:00
?. &(?=({$~ $json} p.pok) ?=($post mef) ?=(^ bod) !is-anon) &
=+ oxe=grab-oryx
2015-03-03 04:52:55 +03:00
?~ oxe |
2015-03-27 01:32:32 +03:00
?: (~(has in vew.cyz:for-client) u.oxe)
&
2015-12-21 00:16:39 +03:00
~&(bad-oryx+[u.oxe vew.cyz:for-client] &) :: XX security
2014-06-10 00:09:14 +04:00
::
++ grab-json
2015-12-06 23:54:14 +03:00
?. ?=(?($post $put $delt) mef)
2015-03-28 04:06:38 +03:00
~
?~(bod ~ (poja q.u.bod))
2014-04-16 23:47:41 +04:00
::
2015-12-20 23:50:45 +03:00
++ need-body |*(a/fist:jo (need (biff grab-json a)))
++ grab-oryx
^- (unit oryx)
2015-12-21 00:16:39 +03:00
=+ oxe=(biff grab-json (ot oryx+so ~):jo)
?^ oxe oxe
(~(get by (molt quy)) %oryx)
2014-04-21 21:02:09 +04:00
::
::
2015-03-28 04:06:38 +03:00
++ parse
^- (each perk httr)
|^ =+ hit=as-magic-filename
?^ hit [%| u.hit]
2015-12-07 22:28:30 +03:00
?: is-spur
[%& %spur (flop q.pok)]
2015-03-28 04:06:38 +03:00
=+ bem=as-beam
?^ bem [%& %beam u.bem]
?. check-oryx
~|(%bad-oryx ~|([grab-oryx vew.cyz:for-client] !!))
2015-03-28 04:06:38 +03:00
=+ hem=as-aux-request
?^ hem [%& u.hem]
2015-12-21 00:16:39 +03:00
~|(strange-path+q.pok !!)
2015-03-28 04:06:38 +03:00
::
++ as-magic-filename
^- (unit httr)
?+ [(fall p.pok %$) q.pok] ~
{?($ico $png) $favicon $~}
2015-03-28 04:06:38 +03:00
:- ~
2015-12-21 00:16:39 +03:00
%^ resp 200 image+/png
2015-05-30 02:47:38 +03:00
favi
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
{$txt $robots $~}
2015-03-28 04:06:38 +03:00
:- ~
2015-12-21 00:16:39 +03:00
%^ resp 200 text+/plain
2015-03-28 04:06:38 +03:00
%- role
:~ 'User-agent: *'
'Disallow: /'
==
==
::
2015-12-07 22:28:30 +03:00
++ is-spur |(?~(q.pok & ((sane %tas) i.q.pok)))
++ as-beam
2015-03-28 04:06:38 +03:00
^- (unit beam)
2015-12-07 22:28:30 +03:00
?~ q.pok ~
=+ ^- (unit {@ dez/desk rel/?}) :: /=desk/, /=desk=/
2015-12-07 22:28:30 +03:00
(rush i.q.pok ;~(plug tis sym ;~(pose (cold | tis) (easy &))))
?~ - (tome q.pok) :: /~ship/desk/case/...
:+ ~ [our dez.u r.top]
?. rel.u (flop t.q.pok)
(weld (flop t.q.pok) s.top) :: /=desk/... as hoon /=desk%/...
2015-03-28 04:06:38 +03:00
::
++ as-aux-request :: /~/... req parser
^- (unit perk)
=. mef
2015-12-06 23:54:14 +03:00
?. ?=($post mef) mef
2015-12-20 23:50:45 +03:00
?+ (skim quy |=({a/@t b/@t} &(=('' b) =(a (cuss (trip a))))))
2015-12-21 00:16:39 +03:00
~|(bad-quy+[req='"?PUT" or "?DELETE"' quy] !!)
2015-12-06 23:54:14 +03:00
$~ mef
{{$'DELETE' $~} $~} %delt
{{$'PUT' $~} $~} %put
2015-03-28 04:06:38 +03:00
==
|-
2015-12-06 23:54:14 +03:00
?: ?=({$'~~' *} q.pok) :: auth shortcuts
2015-03-28 04:06:38 +03:00
$(q.pok ['~' %as %own t.q.pok])
2015-12-06 23:54:14 +03:00
?. ?=({$'~' @ *} q.pok) ~
2015-03-28 04:06:38 +03:00
:- ~ ^- perk
=* pef i.t.q.pok
=+ but=t.t.q.pok :: XX =*
2015-12-21 00:16:39 +03:00
?+ pef ~|(pfix-lost+`path`/~/[pef] !!)
2016-01-25 06:37:41 +03:00
$debug ((hard perk) [%bugs but])
2015-12-06 23:54:14 +03:00
$away [%away ~]
$at [%auth %at pok(q but)]
$am ?~(but !! [%auth %xen i.but pok(q t.but)])
$as
2015-03-28 04:06:38 +03:00
:+ %auth %get
2015-12-21 00:16:39 +03:00
~| bad-ship+?~(but ~ i.but)
2015-03-28 04:06:38 +03:00
?~ but !!
:_ pok(q t.but)
?+ i.but (slav %p i.but)
2015-12-06 23:54:14 +03:00
$anon anon
$own (fall (ship-from-cookies maf) our)
2015-03-28 04:06:38 +03:00
==
::
2015-12-06 23:54:14 +03:00
$on
2015-05-02 00:43:41 +03:00
:- %poll
?^ but [(raid but %uv ~)]~
2015-12-07 03:46:01 +03:00
=+ dep=((hard (list {@ $~})) quy)
2015-05-02 00:43:41 +03:00
=< ?~(. !! .)
2015-12-20 23:50:45 +03:00
(turn dep |=({a/@tas $~} (slav %uv a)))
2015-05-02 00:43:41 +03:00
::
2015-12-06 23:54:14 +03:00
$of
:+ %view ?>(?=({@ $~} but) i.but)
?> ?=({{$poll @} $~} quy) :: XX eventsource
2015-03-28 04:06:38 +03:00
[~ (rash q.i.quy dem)]
::
2015-12-06 23:54:14 +03:00
$to
2015-12-20 23:50:45 +03:00
=+ ^- dir/{p/ship q/term r/mark}
2015-12-21 00:16:39 +03:00
~| bad-mess+but
?+ but !!
{@ @ $~} [our (raid but %tas %tas ~)]
{@ @ @ $~} (raid but %p %tas %tas ~)
==
:^ %mess [p q]:dir r.dir
=+ wir=(~(get by (molt quy)) 'wire')
?^ wir [(stab u.wir) (need grab-json)] :: XX distinguish
2015-12-21 00:16:39 +03:00
(need-body (ot wire+(cu stab so) xyro+some ~):jo)
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
$in
2015-12-21 00:16:39 +03:00
~| expect+[%post 'application+json' /'@uv' '?PUT/DELETE']
2015-12-14 10:58:14 +03:00
?> &(?=(?($delt $put) mef) ?=($@($~ {$~ $json}) p.pok))
2015-03-28 04:06:38 +03:00
[%deps mef (raid but %uv ~)]
::
2015-12-06 23:54:14 +03:00
$is
2015-03-28 04:06:38 +03:00
?~ but
2015-12-21 00:16:39 +03:00
~|(no-app+but=but !!)
2015-03-28 04:06:38 +03:00
|- ^- perk
?~ p.pok $(p.pok [~ %json])
2015-12-06 23:54:14 +03:00
?. ?=($json u.p.pok)
2015-12-21 00:16:39 +03:00
~|(is+stub+u.p.pok !!) :: XX marks
2015-03-28 04:06:38 +03:00
?: ((sane %tas) i.but)
$(but [(scot %p our) but])
2015-12-06 23:54:14 +03:00
?> ?=(?($delt $put) mef)
2015-04-07 22:06:05 +03:00
=+ :- hap=[(slav %p i.but) (slav %tas -.t.but)]
2015-12-21 00:16:39 +03:00
wir=(need-body (ot wire+(cu stab so) ~):jo)
2015-04-07 22:06:05 +03:00
[%subs mef hap u.p.pok wir +.t.but]
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
$auth
2015-03-28 04:06:38 +03:00
:- %auth
|- ^- perk-auth
?+ p.pok !!
2015-12-06 23:54:14 +03:00
$~ $(p.pok [~ %json])
{$~ $js} [%js ~]
{$~ $json}
2015-12-21 00:16:39 +03:00
?+ mef ~|(bad-meth+mef !!)
2015-12-06 23:54:14 +03:00
$get [%json ~]
$put
2015-12-21 00:16:39 +03:00
~| parsing+bod
[%try (need-body (ot ship+(su fed:ag) code+(mu so) ~):jo)]
2015-04-01 00:58:44 +03:00
::
2015-12-06 23:54:14 +03:00
$delt
2015-12-21 00:16:39 +03:00
~| parsing+bod
2015-04-01 00:58:44 +03:00
=+ jon=(need (poja q:(need bod)))
2015-12-06 23:54:14 +03:00
?> ?=($o -.jon)
2015-04-01 00:58:44 +03:00
=+ sip=(~(get by p.jon) %ship)
[%del ?~(sip ~ [~ (need ((su:jo fed:ag) u.sip))])]
2015-03-28 04:06:38 +03:00
== ==
2015-04-01 00:58:44 +03:00
==
2015-03-28 04:06:38 +03:00
--
2014-04-21 21:02:09 +04:00
::
:: process-payload handles the translation of a payload for post.
:: currently this involves treating the payload as a urlencoded
:: request. In the future it's possible the payload could be
:: a specific mark instead.
::
++ process-payload
^- {quay meth}
?+ mef [quy mef]
$post [`quay`(weld quy `quay`(rash q:(need bod) yquy:urlp)) %get]
==
2015-03-28 04:06:38 +03:00
++ process
2015-12-15 01:21:10 +03:00
^- (each pest _done)
2015-03-28 04:06:38 +03:00
=+ pet=parse
2015-12-06 23:54:14 +03:00
?: ?=($| -.pet)
2015-12-29 01:01:44 +03:00
[%& %$ p.pet]
2015-03-28 04:06:38 +03:00
(process-parsed p.pet)
2014-04-16 23:47:41 +04:00
::
2015-03-28 04:06:38 +03:00
++ process-parsed
2015-12-20 23:50:45 +03:00
|= hem/perk ^- (each pest _done)
2015-03-03 04:52:55 +03:00
?- -.hem
2015-12-06 23:54:14 +03:00
$auth (process-auth p.hem)
$away [%& %html logout-page:xml]
?($beam $spur)
=^ payload mef process-payload
2015-03-04 05:22:02 +03:00
=+ ext=(fall p.pok %urb)
=+ bem=?-(-.hem $beam p.hem, $spur [-.top (weld p.hem s.top)])
2016-02-01 09:16:26 +03:00
~| bad-beam+q.bem
2015-05-22 02:47:50 +03:00
?< =([~ 0] (sky %cw (tope bem(+ ~, r [%da now]))))
2015-12-08 03:56:51 +03:00
=+ wir=`whir`[%ha (tope -.bem ~)]
=. wir ?+(mef !! $get wir, $head [%he wir])
=. r.bem ?+(r.bem r.bem {$ud $0} da+now)
=+ arg=(fcgi payload fcgi-cred)
=+ [%bake wir ext arg bem]
?.(aut [%& `pest`-] [%| `_done`(resolve ~ -)])
2015-03-13 03:37:52 +03:00
::
$bugs
2015-03-27 04:01:28 +03:00
?- p.hem
2015-12-06 23:54:14 +03:00
$as (show-login-page)
$to [%& %html poke-test:xml]
2015-03-17 23:55:40 +03:00
==
2015-03-18 00:38:13 +03:00
::
2015-12-06 23:54:14 +03:00
$deps
=+ ire=need-ixor
2015-03-28 04:06:38 +03:00
?> (~(has by wix) ire) :: XX made redundant by oryx checking
=< [%| (nice-json)]
2015-03-17 23:55:40 +03:00
?- p.hem
2015-12-06 23:54:14 +03:00
$put (new-deps q.hem %| ire)
$delt (del-deps q.hem %| ire)
2015-03-17 23:55:40 +03:00
==
2015-03-13 03:37:52 +03:00
::
2015-12-06 23:54:14 +03:00
$mess
:- %|
=^ orx ..ya ?:(is-anon new-view:for-client [(need grab-oryx) ..ya])
2015-06-06 01:07:40 +03:00
=+ vew=(ire-ix (oryx-to-ixor orx))
((teba new-mess.vew) p.hem r.hem q.hem %json !>(`json`s.hem))
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
$poll
?: ?=({$~ $js} p.pok) :: XX treat non-json cases?
=+ deps=[%a (turn `(list @uvH)`p.hem |=(a/@ s+(scot %uv a)))]
[%& %js (add-json (joba %deps deps) poll:js)]
2015-12-01 05:02:41 +03:00
=. lyv (~(put by lyv) hen %wasp p.hem)
2015-05-02 00:43:41 +03:00
|-
2015-12-01 05:02:41 +03:00
=. done (new-deps i.p.hem %& hen)
2015-05-02 00:43:41 +03:00
?~ t.p.hem [%| done]
$(p.hem t.p.hem)
2015-03-17 03:32:44 +03:00
::
2015-12-06 23:54:14 +03:00
$subs
2015-03-27 04:01:28 +03:00
?- p.hem
2015-12-06 23:54:14 +03:00
$put [%| ((teba add-subs:for-view) q.hem)]
$delt [%| ((teba del-subs:for-view) q.hem)]
2015-03-27 04:01:28 +03:00
==
2015-03-17 03:32:44 +03:00
::
2015-12-06 23:54:14 +03:00
$view
2015-12-21 00:16:39 +03:00
~| lost-ixor+p.hem
2015-03-28 04:06:38 +03:00
[%| ((teba poll:(ire-ix p.hem)) u.q.hem)]
==
2014-03-20 05:05:42 +04:00
::
2015-03-28 04:06:38 +03:00
++ process-auth
2015-12-20 23:50:45 +03:00
|= ham/perk-auth ^- (each pest _done)
2015-03-28 04:06:38 +03:00
=+ yac=for-client
?- -.ham
2015-12-06 23:54:14 +03:00
$js [%& %js auth:js]
$json =^ jon ..ya stat-json.yac
2015-03-28 04:06:38 +03:00
[%| (give-json 200 ~ jon)]
2015-12-06 23:54:14 +03:00
$xen (show-login-page ~ ses.ham)
2015-03-13 03:37:52 +03:00
::
2015-12-06 23:54:14 +03:00
$at
2015-03-28 04:06:38 +03:00
=. ..ya abet.yac
2015-05-19 00:34:46 +03:00
=+ pez=process(pok p.ham, aut |)
2015-12-21 00:16:39 +03:00
?. ?=($& -.pez) ~|(no-inject+p.ham !!)
2015-04-02 08:41:39 +03:00
?~ p.pez pez
2015-12-21 00:16:39 +03:00
?+ -.p.pez ~&(bad-inject+p.pez !!)
2015-12-06 23:54:14 +03:00
$red pez
$bake
2015-03-28 04:06:38 +03:00
=. ya abet.yac
2015-04-02 08:41:39 +03:00
[%| (resolve ~ p.pez(p [%at ses.yac p.p.pez]))]
2014-04-09 02:26:01 +04:00
::
2015-12-06 23:54:14 +03:00
$js
2015-03-28 04:06:38 +03:00
=^ jon ..ya stat-json.yac
2015-04-02 08:41:39 +03:00
[%| (resolve cug.yac p.pez(p (add-json jon p.p.pez)))]
2014-03-20 05:05:42 +04:00
==
2015-03-28 04:06:38 +03:00
::
2015-12-06 23:54:14 +03:00
$del
2015-03-28 04:06:38 +03:00
=. ..ya (logoff:yac p.ham)
2015-05-19 00:19:13 +03:00
=+ cug=[(set-cookie cookie-prefix '~')]~
2015-03-28 04:06:38 +03:00
[%| (give-json 200 cug (joba %ok %b &))]
::
2015-12-06 23:54:14 +03:00
$get
2015-05-19 00:19:13 +03:00
|-
2015-12-21 00:16:39 +03:00
~| aute+ham
?: |(=(anon him.ham) (~(has in aut.yac) him.ham))
=. ..ya abet.yac(him him.ham)
2015-05-16 02:21:09 +03:00
=+ pez=process(pok rem.ham, aut &)
2015-12-06 23:54:14 +03:00
?: ?=($| -.pez) pez
2015-05-16 02:21:09 +03:00
[%| (resolve ~ p.pez)]
?. =(our him.ham)
[%| ((teba foreign-auth.yac) him.ham hat rem.ham quy)]
2015-03-28 04:06:38 +03:00
(show-login-page ~)
::
2015-12-06 23:54:14 +03:00
$try
2015-03-28 04:06:38 +03:00
:- %|
?. =(our him.ham)
2015-12-21 00:16:39 +03:00
~|(stub-foreign+him.ham !!)
?. ?| (~(has in aut.yac) him.ham)
?~(paz.ham | =(u.paz.ham load-secret))
==
2015-06-19 20:27:03 +03:00
~& code=`@t`load-secret
~|([%try 'code' %in %console] !!) :: XX security
2015-03-28 04:06:38 +03:00
=^ jon ..ya stat-json:(logon:yac him.ham)
2015-05-19 00:19:13 +03:00
=. cug.yac :_(cug.yac (set-cookie %ship (scot %p him.ham)))
2015-03-28 04:06:38 +03:00
(give-json 200 cug.yac jon)
2014-04-10 03:51:19 +04:00
==
2014-03-12 23:50:39 +04:00
::
2015-03-28 04:06:38 +03:00
++ show-login-page
2015-12-20 23:50:45 +03:00
|= ses/(unit hole) ^- (each pest _done)
2015-12-21 00:16:39 +03:00
%- (slog leaf+"login code for {(scow %p our)}: {(trip load-secret)}" ~)
2015-12-14 10:58:14 +03:00
?. ?=($@($~ {$~ $html}) p.pok)
2015-04-02 08:41:39 +03:00
[%& %red ~]
2015-03-09 23:06:00 +03:00
?~ ses
2015-04-02 08:41:39 +03:00
[%& %htme login-page:xml]
2015-03-28 04:06:38 +03:00
?: (~(has by wup) u.ses)
2015-04-02 08:41:39 +03:00
[%& %htme login-page:xml]
2015-03-28 04:06:38 +03:00
=+ yac=(new-ya u.ses)
=+ =- lon=?~(- | (~(has in aut.u.-) our))
(biff (session-from-cookies cookie-prefix maf) ~(get by wup))
=. yac ?.(lon yac (logon.yac our))
[%| (give-html(..ya abet.yac) 401 cug.yac login-page:xml)]
2014-04-21 21:02:09 +04:00
::
2015-03-09 23:06:00 +03:00
++ cookie-prefix (rsh 3 1 (scot %p our))
2015-05-19 00:19:13 +03:00
++ cookie-domain
^- cord
?- r.hat
2015-12-06 23:54:14 +03:00
{$| @} (cat 3 '; Domain=' (rsh 3 1 (scot %if p.r.hat)))
{$& $org $urbit *} '; Domain=.urbit.org'
{$& @ @ *} =- (rap 3 "; Domain={-}{i.p.r.hat ~}")
(turn (flop `path`t.p.r.hat) |=(a/knot (cat 3 a '.')))
2015-12-06 23:54:14 +03:00
{$& *} '' :: XX security?
2015-05-19 00:19:13 +03:00
==
::
++ set-cookie
2015-12-20 23:50:45 +03:00
|= {key/@t val/@t}
2015-05-19 00:19:13 +03:00
%+ rap 3 :~
key '=' val
:: '; HttpOnly' ?.(sec '' '; Secure') :: XX security
cookie-domain
'; Path=/; HttpOnly'
==
++ need-ixor (oryx-to-ixor (need grab-oryx))
2015-04-07 02:36:07 +03:00
++ for-view ^+(ix (ire-ix need-ixor))
2015-03-28 04:06:38 +03:00
::
2015-03-04 05:22:02 +03:00
++ for-client :: stateful per-session engine
^+ ya
2015-03-09 23:06:00 +03:00
=+ pef=cookie-prefix
2015-03-09 23:55:54 +03:00
=+ lig=(session-from-cookies pef maf)
2015-04-01 00:58:44 +03:00
?~ lig
(new-ya (rsh 3 1 (scot %p (end 6 1 ney))))
2015-05-09 03:34:06 +03:00
=+ cyz=(~(get by wup) u.lig)
?~ cyz
2015-12-21 00:16:39 +03:00
~& bad-cookie+u.lig
2015-05-09 03:34:06 +03:00
(new-ya (rsh 3 1 (scot %p (end 6 1 ney))))
~(. ya u.lig u.cyz(cug ~))
2015-03-09 23:06:00 +03:00
::
2015-12-20 23:50:45 +03:00
++ new-ya |=(ses/hole ~(. ya ses (new-cyst ses)))
2015-03-28 04:06:38 +03:00
++ new-cyst
2015-12-20 23:50:45 +03:00
|= ses/hole
2015-03-09 23:06:00 +03:00
=* sec p.hat
2015-03-03 04:52:55 +03:00
^- cyst
:* ^- cred
:* hat(p sec)
~
'not-yet-implemented'
::(rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses))))
2014-04-21 21:02:09 +04:00
::
2015-03-03 04:52:55 +03:00
=+ lag=(~(get by maf) %accept-language)
?~(lag ~ ?~(u.lag ~ [~ i.u.lag]))
2014-04-21 21:02:09 +04:00
::
2015-03-03 04:52:55 +03:00
cip
~
2014-06-10 00:09:14 +04:00
==
2015-03-03 04:52:55 +03:00
[anon ~]
2014-04-21 21:02:09 +04:00
::
2015-05-19 00:19:13 +03:00
[(set-cookie cookie-prefix ses)]~
2014-04-21 21:02:09 +04:00
::
2015-03-03 04:52:55 +03:00
now
~
2015-03-09 23:06:00 +03:00
~
2015-03-03 04:52:55 +03:00
:: [1 ~]
2014-03-12 23:50:39 +04:00
==
2015-03-03 04:52:55 +03:00
--
2015-03-17 03:32:44 +03:00
::
2015-12-20 23:50:45 +03:00
++ oryx-to-ixor |=(a/oryx (rsh 3 1 (scot %p (end 6 1 (shas %ire a)))))
2014-03-12 23:50:39 +04:00
++ ya :: session engine
2015-12-20 23:50:45 +03:00
=| {ses/hole cyst}
2015-03-04 05:22:02 +03:00
=* cyz ->
2014-03-12 23:50:39 +04:00
|%
2015-03-04 05:22:02 +03:00
++ abet ..ya(wup (~(put by wup) ses cyz))
++ abut ..ya(wup (~(del by wup) ses))
2015-03-28 04:06:38 +03:00
++ foreign-auth
2015-12-20 23:50:45 +03:00
|= {him/ship pul/purl} ^+ ..ya
2015-03-28 04:06:38 +03:00
=. way (~(put by way) him pul hen)
2015-12-21 00:16:39 +03:00
~& asking-foreign+him
(ames-gram:abet him [lon+~ ses])
2014-03-12 23:50:39 +04:00
::
2015-03-28 04:06:38 +03:00
++ foreign-hat
2015-12-20 23:50:45 +03:00
|= {him/ship hat/hart} ^+ ..ya
2015-03-28 04:06:38 +03:00
~| way
=^ pul hen (~(got by way) him)
=: way (~(del by way) him)
dop (~(put by dop) r.hat him)
q.q.pul ['~' %am ses q.q.pul]
2014-06-17 05:33:31 +04:00
==
2015-03-28 04:06:38 +03:00
=+ url=(welp (earn pul(p hat)) '#' (head:earn p.pul))
%- give-thou:abet
2015-12-21 00:16:39 +03:00
(add-cookies cug [307 [location+(crip url)]~ ~])
2014-06-10 00:09:14 +04:00
::
++ logon
2015-12-20 23:50:45 +03:00
|= her/ship
2015-03-09 23:06:00 +03:00
%_ +>
him her
aut (~(put in aut) her)
..ya
2015-12-21 00:16:39 +03:00
~& logon+[our her ses]
2015-03-09 23:06:00 +03:00
?. =(our her)
..ya
=+ sap=(~(get by sop) ses)
~& sap
?. ?=({$~ @ $|} sap)
2015-03-09 23:06:00 +03:00
..ya
2015-12-21 00:16:39 +03:00
(ames-gram -.u.sap aut+~ ses)
2014-06-10 00:09:14 +04:00
==
2015-03-04 05:22:02 +03:00
++ logoff
2015-12-20 23:50:45 +03:00
|= her/(unit ship) ^+ ..ya
2015-03-04 05:22:02 +03:00
?~ her abut
=. aut (~(del in aut) u.her)
?~ aut abut
2016-01-25 06:37:41 +03:00
abet(him ?.(=(u.her him) him n.aut))
2014-06-10 00:09:14 +04:00
::
++ new-view
^+ [*oryx ..ya]
2015-03-27 01:32:32 +03:00
=+ orx=`@t`(rsh 3 1 (scot %p (shaf %orx eny)))
2015-03-04 05:22:02 +03:00
=. vew (~(put in vew) orx)
2015-12-02 01:38:18 +03:00
=+ ire=(oryx-to-ixor orx)
=. ..ix ~(init ix ire %*(. *stem him him, p.eve 1))
2015-12-21 00:16:39 +03:00
:: ~& stat-ire+`@t`ire
[orx abet]
::
++ fcgi-cred %_(ced aut (~(put ju aut.ced) %$ (scot %p him)))
++ stat-json
^+ [*json ..ya]
=^ orx ..ya new-view
:_ ..ya
2015-03-04 05:22:02 +03:00
%- jobe :~
2015-12-21 00:16:39 +03:00
oryx+s+orx
ixor+s+(oryx-to-ixor orx)
ship+(jape +:<our>)
user+(jape +:<him>)
auth+a+(turn (~(tap in aut)) |=(a/@p (jape +:<a>)))
2014-04-09 02:26:01 +04:00
==
2014-03-12 23:50:39 +04:00
--
2015-03-17 03:32:44 +03:00
::
++ ix
2015-12-20 23:50:45 +03:00
=| {ire/ixor stem}
2015-03-17 03:32:44 +03:00
=* sem ->
|%
2015-03-28 04:06:38 +03:00
++ done .
2015-04-07 02:36:07 +03:00
++ abet ..ix(wix (~(put by wix) ire sem))
2015-12-02 01:38:18 +03:00
++ abut
=+ sub=(~(tap in sus))
|- ^+ ..ix
?^ sub $(sub t.sub, ..ix (pul-subs i.sub))
=. +> poll-rest
..ix(wix (~(del by wix) ire))
::
2016-02-04 10:12:23 +03:00
++ teba |*(a/$-(* ..ix) |*(b/* %_(done ..ix (a b))))
2015-04-07 02:36:07 +03:00
++ give-json (teba ^give-json)
2015-12-02 01:38:18 +03:00
++ pass-note (teba ^pass-note)
2015-04-07 02:36:07 +03:00
++ hurl-note
2015-12-20 23:50:45 +03:00
|= {a/{dock path} b/note} ^+ ..ix
2015-04-07 03:32:30 +03:00
=: med (~(put to med) hen)
hen `~
==
2015-12-21 00:16:39 +03:00
:: ~& > hurl+[&2.b ire a]
2015-04-07 03:32:30 +03:00
(pass-note:abet [%of ire (gsig a)] b)
2014-04-09 02:26:01 +04:00
::
2015-12-02 01:38:18 +03:00
++ init
=. die (add ~d1 now)
2015-12-21 00:16:39 +03:00
abet(mow :_(mow [`/ %pass ow+/[ire] [%b %wait die]]))
2015-12-02 01:38:18 +03:00
::
++ refresh
2015-12-21 00:16:39 +03:00
=. mow :_(mow [`/ %pass ow+/[ire] [%b %rest die]])
2015-12-02 01:38:18 +03:00
=. die (add ~d1 now)
2015-12-21 00:16:39 +03:00
done(mow :_(mow [`/ %pass ow+/[ire] [%b %wait die]]))
2015-12-02 01:38:18 +03:00
::
2015-03-28 04:06:38 +03:00
++ add-even
2015-12-20 23:50:45 +03:00
|= a/even ^+ eve
2015-03-28 04:06:38 +03:00
[+(p.eve) (~(put by q.eve) p.eve a)]
2014-04-09 02:26:01 +04:00
::
2015-04-07 02:36:07 +03:00
++ new-mess
2015-12-20 23:50:45 +03:00
|= {a/dock b/wire c/mark d/cage} ^+ ..ix
2015-06-06 01:07:40 +03:00
(hurl-note [a b] [%g %deal [him -.a] +.a %punk c d])
2014-04-23 23:26:22 +04:00
::
2015-03-27 04:01:28 +03:00
++ add-subs
2015-12-20 23:50:45 +03:00
|= {a/dock $json b/wire c/path} ^+ ..ix
2015-12-21 00:16:39 +03:00
?: (~(has in sus) +<) ~|(duplicate+c !!)
2015-12-02 01:38:18 +03:00
=. sus (~(put in sus) +<)
2015-06-06 01:07:40 +03:00
(hurl-note [a b] [%g %deal [him -.a] +.a %peel %json c])
2014-04-23 23:26:22 +04:00
::
2015-12-02 01:38:18 +03:00
++ pul-subs
2015-12-20 23:50:45 +03:00
|= {a/dock $json b/wire c/path} ^+ ..ix
2015-12-02 01:38:18 +03:00
=. sus (~(del in sus) +<)
(hurl-note [a b] [%g %deal [him -.a] +.a %pull ~])
::
2015-04-07 22:06:05 +03:00
++ del-subs :: XX per path?
2015-12-20 23:50:45 +03:00
|= {a/dock $json b/wire c/path} ^+ ..ix
2015-12-02 01:38:18 +03:00
=. ..ix (pul-subs +<)
(nice-json:pop-duct:(ire-ix ire)) :: XX gall ack
::
2015-03-17 03:32:44 +03:00
++ get-rush
2015-12-20 23:50:45 +03:00
|= {a/whir-of b/json} ^+ ..ix
2015-04-07 02:36:07 +03:00
(get-even [%rush [[(slav %p p.a) q.a] r.a] (joba %json b)])
2014-03-12 23:50:39 +04:00
::
2015-12-02 01:38:18 +03:00
++ get-quit
2015-12-20 23:50:45 +03:00
|= a/whir-of ^+ ..ix
2015-12-02 01:38:18 +03:00
(get-even [%quit [[(slav %p p.a) q.a] r.a]])
::
2015-04-07 02:36:07 +03:00
++ get-ack
2015-12-20 23:50:45 +03:00
|= {a/whir-of b/(unit {term tang})} ^+ ..ix
2015-12-21 00:16:39 +03:00
?: =(~ med) ~& resp-lost+ire ..ix
2015-12-02 01:38:18 +03:00
?~ b (nice-json:pop-duct)
(mean-json:pop-duct 500 b)
2014-03-12 23:50:39 +04:00
::
2015-03-17 23:55:40 +03:00
++ get-even
2015-12-20 23:50:45 +03:00
|= ven/even ^+ ..ix
2015-03-19 03:22:20 +03:00
=+ num=p.eve
2015-03-17 23:55:40 +03:00
=. eve (add-even ven)
2015-03-17 03:32:44 +03:00
=< abet
?~ ude done
2015-04-21 02:45:31 +03:00
=. hen p.u.ude
2015-12-02 01:38:18 +03:00
(give-even:pass-rest(ude ~) q.u.ude num ven)
2014-06-10 00:09:14 +04:00
::
2015-03-19 03:22:20 +03:00
++ give-even
2015-12-20 23:50:45 +03:00
|= {pol/? num/@u ven/even} ^+ done
2015-03-27 02:29:17 +03:00
=: q.eve (~(del by q.eve) (dec num)) :: TODO ponder a-2
2015-12-06 23:54:14 +03:00
mow ?.(?=($rush -.ven) mow mow:(pass-took p.ven))
2015-03-27 02:29:17 +03:00
==
2015-04-07 02:36:07 +03:00
?> pol :: XX eventstream
2015-03-19 03:22:20 +03:00
%^ give-json 200 ~
2015-12-21 00:16:39 +03:00
%^ jobe id+(jone num) type+[%s -.ven]
2015-03-19 03:22:20 +03:00
?- -.ven
2015-12-21 00:16:39 +03:00
$news ~[from+[%s (scot %uv p.ven)]]
$quit ~[from+(subs-to-json p.ven)]
$rush ~[from+(subs-to-json p.ven) data+q.ven]
2015-03-19 03:22:20 +03:00
==
::
2015-12-21 00:16:39 +03:00
++ pass-wait (pass-note of+/[ire] [%b %wait era])
2015-12-02 01:38:18 +03:00
++ pass-rest
=. lyv (~(del by lyv) hen)
2015-12-21 00:16:39 +03:00
(pass-note of+/[ire] [%b %rest era])
2015-12-02 01:38:18 +03:00
::
2015-03-28 04:06:38 +03:00
++ pass-took
2015-12-20 23:50:45 +03:00
|= a/{p/dock wire}
2015-05-09 02:02:50 +03:00
%+ pass-note(hen `~)
[%of ire (gsig a)]
2015-05-10 01:55:05 +03:00
[%g %deal [him -.p.a] +.p.a %pump ~]
2014-06-10 00:09:14 +04:00
::
2015-04-07 23:31:09 +03:00
++ pop-duct =^(ned med ~(get to med) abet(hen ned))
2015-03-28 04:06:38 +03:00
++ poll
2015-12-20 23:50:45 +03:00
|= a/@u ^+ ..ix
2015-12-02 01:38:18 +03:00
=< abet
=. ..poll refresh
2015-03-28 04:06:38 +03:00
?: =(a p.eve)
2015-12-02 01:38:18 +03:00
=. ..poll poll-rest
2015-04-07 02:36:07 +03:00
=. era (add ~s30 now)
2015-12-01 05:02:41 +03:00
=. lyv (~(put by lyv) hen [%poll ire])
2015-12-02 01:38:18 +03:00
pass-wait(ude [~ hen &])
2015-12-21 00:16:39 +03:00
?: (gth a p.eve) ~|(seq-high+cur=p.eve !!)
=+ ven=~|(seq-low+cur=p.eve (~(got by q.eve) a))
2015-12-02 01:38:18 +03:00
(give-even & a ven)
::
++ poll-rest
?~ ude done
%*(. pass-rest(hen p.u.ude) hen hen)
2014-06-10 00:09:14 +04:00
::
2015-12-01 05:02:41 +03:00
++ poll-dead
^+ ..ix
2015-12-02 01:38:18 +03:00
=< abet
2015-12-01 05:02:41 +03:00
?. =(ude [~ hen &])
2015-12-02 01:38:18 +03:00
done :: old long poll
pass-rest(ude ~)
2015-12-01 05:02:41 +03:00
::
2015-03-20 02:35:10 +03:00
++ subs-to-json
2015-12-20 23:50:45 +03:00
|= {a/dock b/path}
2015-03-20 02:35:10 +03:00
%- jobe :~
2015-12-21 00:16:39 +03:00
ship+[%s (rsh 3 1 (scot %p p.a))]
appl+[%s q.a]
path+(jape (spud b))
2015-03-20 02:35:10 +03:00
==
2015-03-17 03:32:44 +03:00
++ wake ^+(..ix abet(ude ~)) :: XX other effects?
2015-03-28 04:06:38 +03:00
:: XX unused
2015-12-20 23:50:45 +03:00
++ print-subs |=({a/dock b/path} "{<p.a>}/{(trip q.a)}{(spud b)}")
2015-03-17 03:32:44 +03:00
-- --
2014-03-12 23:50:39 +04:00
--
2015-03-17 03:32:44 +03:00
. ==
2014-03-12 23:50:39 +04:00
=| bolo
=* bol -
|= {now/@da eny/@ ski/sley} :: activate
2014-03-12 23:50:39 +04:00
^? :: opaque core
|% ::
2014-06-04 14:40:09 +04:00
++ call :: handle request
2015-12-20 23:50:45 +03:00
|= $: hen/duct
hic/(hypo (hobo kiss))
2014-06-04 14:40:09 +04:00
==
2014-06-06 03:00:19 +04:00
=> %= . :: XX temporary
q.hic
^- kiss
2015-12-06 23:54:14 +03:00
?: ?=($soft -.q.hic)
2014-06-06 03:00:19 +04:00
((hard kiss) p.q.hic)
?: (~(nest ut -:!>(*kiss)) | p.hic) q.hic
2015-12-06 23:54:14 +03:00
~& [%eyre-call-flub (@tas `*`-.q.hic)]
2014-06-06 03:00:19 +04:00
((hard kiss) q.hic)
==
2015-12-06 23:54:14 +03:00
^+ [p=*(list move) q=..^$]
?: ?=($wegh -.q.hic)
2015-05-07 05:25:41 +03:00
:_ ..^$ :_ ~
:^ hen %give %mass
2015-05-13 00:18:34 +03:00
:- %eyre
2015-05-07 05:25:41 +03:00
:- %|
2015-12-29 01:01:44 +03:00
:~ dependencies+[%& liz] sessions+[%& wup] views+[%& wix]
ducts+[%| ~[dead+[%& ded] proxy+[%& pox] outgoing+[%& ask]]]
hosts+[%& dop]
misc+[%& bol]
2015-05-07 05:25:41 +03:00
==
2015-02-27 00:23:46 +03:00
=+ our=`@p`0x100 :: XX sentinel
=+ ska=(sloy ski)
=+ sky=|=({* *} `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a]))))
=. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need
2015-12-06 23:54:14 +03:00
^+ [p=*(list move) q=..^$]
2016-01-25 06:37:41 +03:00
=. gub ?.(=(`@`0 gub) gub (cat 3 (rsh 3 1 (scot %p (end 6 1 eny))) '-'))
=^ mos bol
2015-02-11 22:26:42 +03:00
abet:(apex:~(adit ye [hen [now eny our sky] ~] bol) q.hic)
2014-03-12 23:50:39 +04:00
[mos ..^$]
2013-09-29 00:21:18 +04:00
::
2015-02-27 03:04:12 +03:00
++ doze :: require no timer
2015-12-20 23:50:45 +03:00
|= {now/@da hen/duct}
2015-12-06 23:54:14 +03:00
^- (unit @da)
2013-09-29 00:21:18 +04:00
~
::
2015-04-15 00:16:46 +03:00
++ load :: take previous state
|= old/bolo
..^$(+>- old)
2013-09-29 00:21:18 +04:00
::
++ scry
|= {fur/(unit (set monk)) ren/@tas who/ship syd/desk lot/coin tyl/path}
^- (unit (unit cage))
=+ our=(need hov) :: XX single home
=+ ska=(sloy ski)
=+ sky=|=({* *} `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a]))))
?. ?=($$ ren) [~ ~]
?. ?=($$ -.lot) [~ ~]
?+ syd [~ ~]
$host
%- (lift (lift |=(a/hart [%hart !>(a)])))
^- (unit (unit hart))
?. =(our who)
?. =([%da now] p.lot) [~ ~]
~& [%e %scry-foreign-host who]
~ :: XX add non-scry binding to $hat gram
=. p.lot ?.(=([%da now] p.lot) p.lot [%tas %real])
?+ p.lot [~ ~]
{$tas $fake} ``[& [~ 8.443] %& /localhost] :: XX from unix
{$tas $real}
``~(our-host ye [`duct`~[/] [now eny our sky] ~] bol)
==
==
2013-09-29 00:21:18 +04:00
::
2014-05-31 23:40:02 +04:00
++ stay `bolo`+>-.$
2014-06-04 14:40:09 +04:00
++ take :: accept response
2015-12-20 23:50:45 +03:00
|= {tea/wire hen/duct hin/(hypo sign)}
2015-12-06 23:54:14 +03:00
^+ [p=*(list move) q=..^$]
2015-02-27 00:23:46 +03:00
=+ our=`@p`0x100 :: XX sentinel
=+ ska=(sloy ski)
=+ sky=|=({* *} `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a]))))
2014-06-04 14:40:09 +04:00
=. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need
^+ [p=*(list move) q=..^$]
2016-01-25 06:37:41 +03:00
=. gub ?.(=(`@`0 gub) gub (cat 3 (rsh 3 1 (scot %p (end 6 1 eny))) '-'))
2015-03-17 23:55:40 +03:00
=+ tee=((soft whir) tea)
?~ tee ~& [%e %lost -.q.hin hen] [~ ..^$]
2014-06-04 14:40:09 +04:00
=^ mos bol
=< abet
2015-03-17 23:55:40 +03:00
%^ axon:~(adit ye [hen [now eny our sky] ~] bol) u.tee
2014-06-24 21:32:59 +04:00
(~(peek ut p.hin) %free 3)
2014-06-22 06:51:12 +04:00
q.hin
2014-06-04 14:40:09 +04:00
[mos ..^$]
2013-09-29 00:21:18 +04:00
--