urbit/arvo/eyre.hoon

1217 lines
42 KiB
Plaintext
Raw Normal View History

!: :: %eyre, http servant
2014-03-12 23:50:39 +04:00
!? 164
::::
2013-12-15 09:42:27 +04:00
|= pit=vase
2013-09-29 00:21:18 +04:00
=> =~
2014-06-07 22:36:31 +04:00
|% :: interfaces
2014-06-03 09:07:32 +04:00
++ gift :: out result <-$
2014-07-15 06:45:04 +04:00
$% [%thou p=httr] :: raw http response
2014-06-04 14:40:09 +04:00
[%thus p=@ud q=(unit hiss)] :: http request/cancel
2014-10-04 02:32:10 +04:00
[%veer p=@ta q=path r=@t] :: drop-through
[%vega p=path] :: drop-through
2015-02-10 04:52:29 +03:00
== ::
2015-02-20 02:33:39 +03:00
++ gram :: inter-ship message
$? [[%lon ~] p=hole] :: login request
[[%aut ~] p=hole] :: login reply
[[%hat ~] p=hole q=hart] :: login redirect
2015-03-23 22:35:25 +03:00
[[%get ~] p=@uvH q=[? clip httq]] :: remote request
[[%got ~] p=@uvH q=httr] :: remote response
2015-02-20 02:33:39 +03:00
== ::
2014-09-11 03:35:03 +04:00
++ hasp ,[p=ship q=term] :: don't see %gall
++ hapt ,[p=ship q=path] :: do see %gall
2014-06-03 09:07:32 +04:00
++ kiss :: in request ->$
2014-06-04 14:40:09 +04:00
$% [%born ~] :: new unix process
[%crud p=@tas q=(list tank)] :: XX rethink
2014-06-04 14:40:09 +04:00
[%init p=@p] :: report install
2015-03-23 23:58:08 +03:00
[%them p=(unit hiss)] :: outbound request
[%they p=@ud q=httr] :: inbound response
2014-06-04 14:40:09 +04:00
[%this p=? q=clip r=httq] :: inbound request
[%thud ~] :: inbound cancel
2015-03-09 23:06:00 +03:00
[%wart p=sack q=@tas r=_`[path *]`*gram] :: urbit message
2014-06-04 14:40:09 +04:00
== ::
2014-06-22 09:49:10 +04:00
++ move ,[p=duct q=(mold note gift)] :: local move
2014-06-03 09:07:32 +04:00
++ note :: out request $->
2015-03-09 23:06:00 +03:00
$% $: %a :: to %ames
$% [%want p=sock q=[path *]] ::
== == ::
2014-06-22 06:51:12 +04:00
$: %d :: to %dill
$% [%flog p=[%crud p=@tas q=(list tank)]] ::
2015-03-23 22:35:25 +03:00
== == ::
$: %e :: to self
$% [%this p=? q=clip r=httq] :: proxied request
2014-06-22 06:51:12 +04:00
== == ::
$: %f :: to %ford
$% [%exec p=@p q=(unit silk)] ::
2015-02-19 00:35:22 +03:00
[%wasp p=@p q=@uvH] ::
2015-03-12 02:51:04 +03:00
== == ::
$: %g :: to %gall
$% [%mess p=hapt q=ship r=cage] ::
[%nuke p=hapt q=ship] ::
[%show p=hapt q=ship r=path] ::
2015-03-17 03:32:44 +03:00
[%took p=hapt q=ship] ::
== == ::
$: %t :: to %temp
$% [%wait p=@da] ::
[%rest p=@da] ::
2015-02-27 00:17:29 +03:00
== == == ::
2014-07-12 22:24:52 +04:00
++ silk :: see %ford
$& [p=silk q=silk] ::
$% [%boil p=mark q=beam r=path] ::
2014-07-27 14:26:17 +04:00
[%cast p=mark q=silk] ::
2014-07-12 22:24:52 +04:00
[%done p=(set beam) q=cage] ::
== ::
2014-10-04 02:32:10 +04:00
++ sine ::
$? sign ::
$: %g ::
$% [%veer p=@ta q=path r=@t] ::
[%vega p=path] ::
== == == ::
2014-06-22 09:49:10 +04:00
++ sign :: in result $<-
2015-03-23 23:33:15 +03:00
$? $: %a :: by %ames
$% [%went p=ship q=cape] ::
== == ::
$: %e :: by self
2015-03-23 22:35:25 +03:00
$% [%thou p=httr] :: response for proxy
== == ::
$: %f :: by %ford
2015-02-19 00:35:22 +03:00
$% [%made p=@uvH q=(each cage tang)] ::
[%news ~] ::
2015-03-12 02:51:04 +03:00
== == ::
$: %g :: by %gall
$% [%dumb ~] ::
[%mean p=ares] ::
[%nice ~] ::
[%rush p=mark q=*] ::
[%rust p=mark q=*] ::
2015-03-17 03:32:44 +03:00
== == ::
$: %t :: by %time
$% [%wake ~] :: timer activate
2015-02-19 00:35:22 +03:00
== == ::
2014-06-22 06:51:12 +04:00
$: @tas :: by any
$% [%crud p=@tas q=(list tank)] ::
== == == ::
2015-03-17 03:32:44 +03:00
++ ixor ,@t :: oryx hash
2015-03-12 02:51:04 +03:00
++ whir $| ~ :: wire subset
2015-03-17 03:32:44 +03:00
$% [%at p=hole q=whir] :: authenticated
2015-03-23 22:35:25 +03:00
[%ay p=span:ship q=span:,@uvH ~] :: remote duct
2015-03-17 03:32:44 +03:00
[%of p=ixor ~] :: associated view
2015-03-17 23:55:40 +03:00
[%on p=span:,@uvH ~] :: dependency
2015-04-02 08:41:39 +03:00
[%to p=span:ship q=[span:ship term ~]] :: associated poke
2015-03-12 02:51:04 +03:00
== ::
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
2014-05-31 02:10:39 +04:00
$: %0 :: version
gub=@t :: random identity
2014-06-10 00:09:14 +04:00
hov=(unit ship) :: master for remote
2014-03-12 23:50:39 +04:00
ged=duct :: client interface
2015-03-23 22:35:25 +03:00
pox=(map ,@uvH duct) :: proxied sessions
2015-03-23 23:58:08 +03:00
ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number
kes=(map duct ,@ud) :: outgoing by duct
2014-03-12 23:50:39 +04:00
ney=@uvI :: rolling entropy
dop=(map host ship) :: host aliasing
2015-03-17 23:55:40 +03:00
liz=(jug ,@uvH (each duct ixor)) :: ford depsets
2015-02-26 04:20:45 +03:00
wup=(map hole cyst) :: secure sessions
2015-03-09 23:06:00 +03:00
sop=(map hole ,[ship ?]) :: foreign session names
2015-03-17 03:32:44 +03:00
wix=(map ixor stem) :: open views
2014-06-10 00:09:14 +04:00
== ::
2015-03-03 04:52:55 +03:00
::
2015-02-18 00:05:28 +03:00
++ cyst :: client session
$: ced=cred :: credential
2015-03-04 05:22:02 +03:00
[him=ship aut=(set ship)] :: authenticated
2015-02-18 00:05:28 +03:00
cug=(list ,@t) :: unacked cookies
lax=@da :: last used
2015-03-09 23:06:00 +03:00
way=(map ship ,[purl duct]) :: waiting auth
2015-03-04 05:22:02 +03:00
vew=(set oryx) :: open views XX expire
2015-02-18 00:05:28 +03:00
== ::
2015-03-03 04:52:55 +03:00
::
2015-03-17 03:32:44 +03:00
++ stem :: client view
2015-03-27 01:32:32 +03:00
$: him=ship :: static identity
2015-03-17 03:32:44 +03:00
ude=(unit ,[p=duct q=?]) :: stream, long-poll?
era=@da :: next wake
2015-03-27 04:01:28 +03:00
eve=[p=@u q=(map ,@u even)] :: queued events
sud=(map ,[hasp path] duct) :: cancel data
dus=(map duct ,[hasp path]) :: subscription by duct
2015-03-17 03:32:44 +03:00
==
::
++ even :: client event
2015-03-28 04:06:38 +03:00
$% [%mean p=[hasp path] q=ares]
[%news p=@uv]
2015-03-27 04:01:28 +03:00
[%rush p=[hasp path] q=json]
2015-03-17 03:32:44 +03:00
==
::
2015-03-03 04:52:55 +03:00
++ perk :: parsed request
2015-03-28 04:06:38 +03:00
$% [%auth p=perk-auth]
2015-03-09 23:55:54 +03:00
[%away ~]
2015-03-13 03:37:52 +03:00
[%bugs p=?(%as %to) ~]
2015-03-28 04:06:38 +03:00
[%beam p=beam]
[%deps p=?(%put %delt) q=@uvH]
2015-03-17 03:32:44 +03:00
[%mess p=hasp q=mark r=json]
2015-03-28 04:06:38 +03:00
[%poll p=@uvH]
[%spur p=spur]
[%subs p=?(%put %delt) q=[hasp %json q=path]]
2015-03-17 03:32:44 +03:00
[%view p=ixor q=[~ u=@ud]]
2015-03-03 04:52:55 +03:00
==
2015-03-17 03:32:44 +03:00
2015-03-03 04:52:55 +03:00
::
++ perk-auth :: parsed auth
2015-03-28 04:06:38 +03:00
$% [%at p=pork] :: inject auth
[%del p=(unit ship)]
[%get him=ship rem=pork]
2015-03-03 04:52:55 +03:00
[%js ~]
2015-03-04 05:22:02 +03:00
[%json ~]
2015-03-03 04:52:55 +03:00
[%try him=ship cod=cord]
2015-03-28 04:06:38 +03:00
[%xen ses=hole rem=pork]
2015-03-03 04:52:55 +03:00
==
2015-03-04 05:22:02 +03:00
::
++ pest :: result
2015-03-14 02:45:03 +03:00
$| ~
2015-04-02 08:41:39 +03:00
$% [%| p=whir q=note] :: further request
[%$ p=httr] :: direct response
[%red ~] :: parent redirect
::
[%js p=@t] :: script
[%json p=json] :: data
[%html p=manx] :: successful page
[%htme p=manx] :: authentication failure
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
|= hed=(list ,[p=@t q=@t]) ^- math
%+ roll hed
|= [a=[p=cord cord] b=math]
=. p.a (cass (trip p.a))
(~(add ja b) a)
::
++ fcgi :: credential caboose
|= [quy=quay ced=cred] ^- coin
:* %many
[%$ %ta ~]
[%blob ced]
|- ^- (list coin)
?~ quy ~
[[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)]
==
::
2015-03-09 23:55:54 +03:00
++ session-from-cookies
2015-03-03 04:52:55 +03:00
|= [nam=@t maf=math]
2015-02-18 00:05:28 +03:00
^- (unit hole)
=+ ^= cok ^- (list ,@t)
2015-03-03 04:52:55 +03:00
=+ cok=(~(get by maf) 'cookie')
2015-02-18 00:05:28 +03:00
?~(cok ~ u.cok)
|- ^- (unit hole)
?~ cok ~
=+ mar=`(unit (list ,[p=@t q=@t]))`(rush i.cok cock:epur)
?~ mar $(cok t.cok)
|- ^- (unit hole)
?~ u.mar ^$(cok t.cok)
2015-03-09 23:55:54 +03:00
?: &(=(nam p.i.u.mar) !=('~' q.i.u.mar))
[~ q.i.u.mar]
$(u.mar t.u.mar)
2015-02-27 00:23:46 +03:00
::
2015-03-12 02:51:04 +03:00
++ wush
|= [wid=@u tan=tang]
^- tape
=+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a))))
(rolt (turn tan |=(a=tank (rolt (wash 0^wid a)))))
::
2015-03-28 04:06:38 +03:00
::
++ add-cookies
|= [cug=(list ,@t) hit=httr] ^- httr
?~ cug hit
=+ cuh=(turn `(list ,@t)`cug |=(a=@t set-cookie/a))
hit(q (weld cuh q.hit))
::
++ add-poll :: inject dependency
|= [dep=@uvH max=[[%html ~] [[%head ~] hed=marl] [[%body ~] manx marl] ~]]
^- manx
?~ dep max
max(hed :_(hed.max ;script@"/~/on/{<dep>}.js";))
::
++ add-json :: inject window.urb
|= [urb=json jaz=cord] ^- cord
(cat 3 (crip "window.urb = {(pojo urb)}\0a") jaz)
::
++ ares-to-json
|= err=ares ^- json
=- (jobe fail/s/typ mess/(jape mez) ~)
^- [typ=term mez=tape]
?~ err [%fail "Unknown Error"]
[p.u.err (wush 160 q.u.err)]
::
++ resp :: mimed response
|= [sas=@uG mit=mite rez=@] ^- httr
:: (weld (turn cug |=(a=@t ['set-cookie' a]))
[sas ~[content-type/(moon mit)] [~ (taco rez)]]
::
++ render-tang :: tanks to manx
2015-03-12 02:51:04 +03:00
|= tan=tang
2015-02-17 02:19:58 +03:00
;html
;head
;meta(charset "utf-8");
;title: server error
==
2015-03-12 02:51:04 +03:00
;body:pre:code:"{(wush 160 tan)}"
2015-02-17 02:19:58 +03:00
==
::
2015-02-11 22:26:42 +03:00
++ js :: static javascript
|%
2015-02-27 03:04:12 +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-02-14 06:43:17 +03:00
xhr = new XMLHttpRequest()
xhr.open('GET', urb.poll, true)
2015-02-11 22:26:42 +03:00
xhr.addEventListener('load', function() {
2015-02-17 02:19:58 +03:00
// if(~~(this.status / 100) == 4)
// return document.write(xhr.responseText)
if(this.status !== 205) {
2015-02-14 06:43:17 +03:00
return urb.keep()
2015-02-11 22:26:42 +03:00
}
2015-02-14 06:43:17 +03:00
document.location.reload()
})
xhr.addEventListener('error', urb.keep)
xhr.addEventListener('abort', urb.keep)
xhr.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-02-14 06:43:17 +03:00
urb.call()
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-13 03:37:52 +03:00
if(window.ship) ship.innerText = urb.ship
2015-03-09 23:06:00 +03:00
urb.foreign = /^\/~\/am/.test(window.location.pathname)
urb.submit = function(){
2015-03-09 23:55:54 +03:00
req(
"/~/auth.json?PUT",
{ship: ship.innerText, code: pass.value},
function(){
if(urb.foreign) document.location =
2015-03-09 23:06:00 +03:00
document.location.hash.match(/#[^?]+/)[0].slice(1) +
document.location.pathname.replace(
/^\/~\/am\/[^/]+/,
'/~/as/~' + urb.ship) +
document.location.search
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", {},
2015-03-13 03:37:52 +03:00
function(){document.write("success!")}
)}
2015-03-03 04:52:55 +03:00
'''
--
++ xml
|%
++ login-page
2015-03-13 03:37:52 +03:00
%+ titl 'Log in'
;= ;p: Identify yourself, ~;{span#ship(contenteditable "")}?
2015-03-04 05:22:02 +03:00
;style:'#ship {background: lightgray} #ship br {display: none}'
2015-03-03 04:52:55 +03:00
;input#pass(onchange "urb.submit()");
;pre:code#err;
2015-03-04 05:22:02 +03:00
;script@"/~/at/~/auth.js";
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'
;= ;p: Goodbye ~;{span#ship}.
2015-03-09 23:55:54 +03:00
;button#act(onclick "urb.away()"): Log out
;pre:code#err;
;script@"/~/at/~/auth.js";
==
2015-03-13 03:37:52 +03:00
::
++ poke-test
%+ titl 'Poke'
;= ;button(onclick "urb.testPoke('/~/to/hi/txt.json')"): Hi anonymous
;button(onclick "urb.testPoke('/~/as/own/~/to/hi/txt.json')"): Hi
;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){
2015-03-18 00:38:13 +03:00
req(url,{xyro:{test:true}}, show)
2015-03-13 03:37:52 +03:00
}
'''
==
++ titl |=([a=cord b=marl] ;html:(head:title:"{(trip a)}" body:"*{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
2014-06-04 14:40:09 +04:00
=| $: $: hen=duct :: event floor
2014-03-12 23:50:39 +04:00
$: now=@da :: event date
eny=@ :: unique entropy
2015-02-11 22:26:42 +03:00
our=ship :: current ship
2014-03-12 23:50:39 +04:00
sky=$+(* (unit)) :: system namespace
== ::
2014-03-12 23:50:39 +04:00
mow=(list move) :: pending actions
== ::
bolo :: all vane state
== ::
=* bol ->
|%
2015-02-27 03:04:12 +03:00
++ abet :: resolve moves
2014-03-12 23:50:39 +04:00
^- [(list move) bolo]
[(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
2013-09-29 00:21:18 +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
2014-06-04 14:40:09 +04:00
|= kyz=kiss
^+ +>
2015-03-09 23:06:00 +03:00
=. our ?~(hov our u.hov) :: XX
2014-06-04 14:40:09 +04:00
?- -.kyz
%born +>.$(ged hen) :: register external
%crud
+>.$(mow [[hen %slip %d %flog kyz] mow])
2015-03-28 04:06:38 +03:00
::
2014-03-23 23:42:18 +04:00
%init :: register ownership
2015-03-28 04:06:38 +03:00
+>.$(hov ?~(hov [~ p.kyz] [~ (min u.hov p.kyz)]))
2015-02-18 00:05:28 +03:00
::
2014-03-12 23:50:39 +04: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)
2015-03-03 04:52:55 +03:00
| =+ hot=(~(get ja maf) %host)
2015-02-11 22:26:42 +03:00
?> ?=([@ ~] 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))
2015-03-28 04:06:38 +03:00
(handle pul [anon 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)
2015-03-23 23:58:08 +03:00
::
%them :: outbound request
?~ p.kyz
=+ sud=(need (~(get by kes) hen))
%= +>.$
mow :_(mow [ged [%give %thus sud ~]])
q.ask (~(del by q.ask) sud)
kes (~(del by kes) hen)
==
:: ~& eyre-them/(earn p.u.p.kyz)
%= +>.$
mow :_(mow [ged [%give %thus p.ask p.kyz]])
p.ask +(p.ask)
q.ask (~(put by q.ask) p.ask hen u.p.kyz)
kes (~(put by kes) hen p.ask)
==
::
%they :: inbound response
=+ kas=(need (~(get by q.ask) p.kyz))
:: ~& > eyre-they/[p.q.kyz (earn p.q.kas)]
%= +>.$
mow :_(mow [p.kas [%give %thou q.kyz]])
q.ask (~(del by q.ask) p.kas)
==
::
%thud :: cancel request
2015-03-28 04:06:38 +03:00
:: ford-kill :: XX discriminate
2015-02-06 08:00:35 +03:00
+>.$
2015-02-20 02:33:39 +03:00
::
%wart :: remote request
=+ mez=((soft gram) r.kyz)
?~ mez
~& [%strange-wart p.kyz q.kyz]
+>.$
2015-03-09 23:06:00 +03:00
?- -<.u.mez
%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)
%get (pass-note ay/(dray p/uv/~ q.p.kyz p.u.mez) [%e %this q.u.mez])
%got
=: hen (~(got by pox) p.u.mez)
pox (~(del by pox) p.u.mez)
==
(give-thou q.u.mez)
::
2015-03-09 23:06:00 +03:00
%lon
~& ses-ask/[p.u.mez sop (~(run by wup) ,~)]
?: (ses-authed p.u.mez)
(ames-gram q.p.kyz aut/~ p.u.mez)
=. sop (~(put by sop) p.u.mez q.p.kyz |)
(ames-gram q.p.kyz hat/~ p.u.mez our-host)
2015-02-20 02:33:39 +03:00
==
2014-03-12 23:50:39 +04:00
==
2013-09-29 00:21:18 +04:00
::
2015-03-28 04:06:38 +03:00
++ axon :: accept response
|= [tee=whir typ=type sih=sign]
^+ +>
:: %- emule |. ^+ ..axon
=. our ?~(hov our u.hov) :: XX
?- &2.sih
%crud +>.$(mow [[hen %slip %d %flog +.sih] mow])
%dumb (emule |.(~|(%gall-stub !!)))
%went +>.$
%thou
?> ?=([%ay ^] tee)
(ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih)
::
?(%rush %rust)
?> ?=([%of ^] tee)
?. ?=(%json p.sih)
=- (back tee 0v0 %json -)
`cage`[p.sih (slot 3 (spec (slot 3 [typ +.sih])))]
(get-rush:(ire-ix p.tee) ((hard json) q.sih))
::
%nice ~|(tee ?>(?=($|(~ [%of ^]) tee) (nice-json)))
%mean
~| tee
?+ tee !!
~ (mean-json 500 p.sih)
[%of ^] (get-mean:(ire-ix p.tee) p.sih) :: XX initial mean
==
::
%wake
?> ?=([%of ^] tee)
=> wake:(ire-ix p.tee)
(give-json 200 ~ (joba %beat %b &))
::
%news :: dependency updated
?. ?=([%on ^] tee)
~&(e/lost/[tee hen] +>.$)
=+ dep=(slav %uv p.tee)
%+ roll (~(tap in (~(get ju liz) dep)))
=< .(con ..axon(liz (~(del by liz) dep)))
|= [sus=(each duct ixor) con=_..axon]
=. ..axon con
?- -.sus
%& (give-json(hen p.sus) 205 ~ %b &)
%| (get-even:(ire-ix p.sus) [%news dep])
==
::
%made
=. our (need hov) :: XX
|- ^+ ..axon
?- tee
[?(%on %ay) *] ~|(e/ford/lost/-.tee !!)
[%of ^]
%- get-rush:(ire-ix p.tee)
?> ?=([%& %json ^] q.sih) :: XX others
((hard json) |3.q.sih)
::
[%to ^]
?: ?=(%| -.q.sih)
(mean-json 500 ~ %cast-fail p.q.sih)
~| tee
2015-04-02 08:41:39 +03:00
=+ [him=(slav %p p.tee) `hap=hapt`q.tee(- (slav %p -.q.tee))]
(pass-note ~ %g [%mess hap him p.q.sih])
2015-03-28 04:06:38 +03:00
::
[%at ^]
?. ?=([%& %js ^] q.sih)
~& e/at-lost/p.tee
$(tee q.tee)
=* cay p.q.sih
?> ?=(@ q.q.cay)
=+ 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.cay))
::
~
:: ~& e/ford/hen
?. ?=(%& -.q.sih)
(fail 404 p.sih p.q.sih)
=* cay p.q.sih
?. ?=(%mime p.cay)
(back tee p.sih %mime cay)
~| q.q.cay
=+ ((hard ,[mit=mite rez=octs]) q.q.cay)
(give-thou 200 [content-type/(moon mit)]~ ~ rez)
==
==
::
++ emule
|= a=_|?(..emule) ^+ ..emule
=+ mul=(mule a)
?~ -.mul p.mul
(fail 500 0v0 >%exit< p.mul)
::
++ ire-ix |=(ire=ixor ~(. ix ire (~(got by wix) ire)))
2015-03-09 23:06:00 +03:00
++ ses-authed
|= ses=hole
=+ sap=(~(get by sop) ses)
?: ?=([~ @ %&] sap) &
=+ cyz=(~(get by wup) ses)
?~ cyz |
(~(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))]
:: [| [~ 8.445] `/localhost] :: XX testing
2015-03-28 04:06:38 +03:00
::
++ ames-gram
|=([him=ship gam=gram] (pass-note ~ %a %want [our him] [%e -.gam] +.gam))
::
++ back :: %ford bounce
|= [tea=whir dep=@uvH mar=mark cay=cage]
2015-04-02 08:41:39 +03:00
(pass-note tea (ford-req [%cast mar %done ~ cay])) :: XX deps
2015-03-28 04:06:38 +03:00
::
++ ford-kill (pass-note ~ %f [%exec our ~]) :: XX unused
2015-04-02 08:41:39 +03:00
++ ford-req |=(kas=silk [%f [%exec our `kas]])
2015-03-28 04:06:38 +03:00
::
++ fail
2015-03-03 04:52:55 +03:00
|= [sas=@ud dep=@uvH mez=tang]
^+ +>
2015-03-28 04:06:38 +03:00
:: (back ~ dep %tang !>(mez)) :: tang->urb chain may be source of failure
(give-html sas ~ (add-poll dep (render-tang mez)))
2015-03-03 04:52:55 +03:00
::
2015-03-28 04:06:38 +03:00
++ give-html
2015-03-09 23:06:00 +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-03-27 01:32:32 +03:00
(resp sas text//html (crip (poxo max)))
2015-03-03 04:52:55 +03:00
::
2015-03-28 04:06:38 +03:00
++ give-json
2015-03-03 04:52:55 +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-03-27 01:32:32 +03:00
(resp sas application//json (crip (pojo jon)))
2015-03-09 23:06:00 +03:00
::
2015-03-28 04:06:38 +03:00
++ give-thou :: done request
|= hit=httr
+>(mow :_(mow [hen %give %thou hit]))
2015-03-03 04:52:55 +03:00
::
2015-03-28 04:06:38 +03:00
++ mean-json |=([sas=@uG err=ares] (give-json sas ~ (ares-to-json err)))
++ nice-json |=(* (give-json 200 ~ (joba %ok %b &)))
2015-03-03 04:52:55 +03:00
::
2015-03-09 23:06:00 +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
2014-03-12 23:50:39 +04:00
|= hot=host
^- (unit ship)
=+ gow=(~(get by dop) hot)
?^ gow gow
2015-02-27 03:04:12 +03:00
?. ?=(& -.hot) ~
=+ dom=(flop p.hot) :: domain name
?~ dom ~
(rush i.dom fed:ag)
2013-09-29 00:21:18 +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 %a pax))))
::
::
++ handle
|= $: [hat=hart pok=pork quy=quay] :: purl, parsed url
2015-03-12 02:51:04 +03:00
[him=ship cip=clip] :: client ip
2015-03-03 04:52:55 +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
|%
++ abet ..handle
2015-03-03 04:52:55 +03:00
++ done .
2015-03-28 04:06:38 +03:00
++ teba |*(a=$+(* ..handle) |*(b=* %_(done ..handle (a b))))
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)
2015-02-19 02:25:55 +03:00
::
2015-03-28 04:06:38 +03:00
++ ford-get-beam
|= [bem=beam ext=term]
=: s.bem [%web ~(rent co (fcgi quy fcgi-cred:for-client)) s.bem]
2015-03-03 04:52:55 +03:00
r.bem ?+(r.bem r.bem [%ud %0] da/now)
2015-04-02 08:41:39 +03:00
==
(ford-req [%boil ext bem ~])
2015-02-06 08:00:35 +03:00
::
2015-03-03 04:52:55 +03:00
::
2015-03-28 04:06:38 +03:00
++ apex
=< 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-03-28 04:06:38 +03:00
?: ?=(%| -.pez) p.pez
2015-04-02 08:41:39 +03:00
(resolve ~ p.pez)
2015-03-19 03:22:20 +03:00
::
2015-03-28 04:06:38 +03:00
++ resolve
2015-04-02 08:41:39 +03:00
|= [cug=(list ,@t) pez=pest] ^+ done
?~ pez done
2015-03-19 03:22:20 +03:00
?- -.pez
2015-04-02 08:41:39 +03:00
~ (give-thou (add-cookies cug p.pez))
| (pass-note +.pez)
%js $(pez [~ (resp 200 text//javascript p.pez)])
%json (give-json 200 cug p.pez)
%html (give-html 200 cug p.pez)
%htme (give-html 401 cug p.pez)
2015-03-13 03:17:00 +03:00
%red
=+ url=(earn hat pok(p [~ %html]) quy)
2015-03-28 04:06:38 +03:00
?+ p.pok ~|(bad-redirect/[p.pok url] !!)
2015-03-13 03:17:00 +03:00
[~ %js]
2015-04-02 08:41:39 +03:00
$(pez [%js auth-redir:js])
2015-03-13 03:17:00 +03:00
[~ %json]
2015-04-02 08:41:39 +03:00
$(pez [%json (jobe ok/b/| red/(jape url) ~)])
2015-03-13 03:17:00 +03:00
==
2015-03-14 02:45:03 +03:00
==
::
2015-02-18 00:05:28 +03:00
::
2015-03-03 04:52:55 +03:00
++ check-oryx :: | if json with bad oryx
^- ?
?. &(?=([~ %json] p.pok) ?=(%post mef) ?=(^ bod)) &
2015-03-28 04:06:38 +03:00
=+ oxe=(grab-body to-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)
&
~&(bad-oryx/[u.oxe vew.cyz:for-client] &) :: XX security
2015-02-18 00:05:28 +03:00
::
2015-03-28 04:06:38 +03:00
++ grab-body
|* a=fist:jo ^+ *a
2015-04-01 00:58:44 +03:00
?. &(?=(^ bod) ?=(?(%post %put %delt) mef))
2015-03-28 04:06:38 +03:00
~
%.(q.u.bod ;~(biff poja a))
::
++ need-body |*(a=fist:jo (need (grab-body a)))
2015-03-04 05:22:02 +03:00
++ root-beak `beak`[our %main ud/0] :: XX
2015-03-28 04:06:38 +03:00
++ to-oryx (ot oryx/so ~):jo
::
::
++ new-dependency
2015-03-17 23:55:40 +03:00
|= [a=@uvH b=(each duct ixor)] ^+ done
?~ a done
=+ had=(~(has by liz) a)
=. liz (~(put ju liz) a b)
?: had done
(pass-note on//(scot %uv a) %f [%wasp our a])
::
2015-03-28 04:06:38 +03:00
++ parse
^- (each perk httr)
|^ =+ hit=as-magic-filename
?^ hit [%| u.hit]
=+ bem=as-beam
?^ bem [%& %beam u.bem]
?. check-oryx
~|(%bad-oryx ~|([(grab-body to-oryx) vew.cyz:for-client] !!))
=+ hem=as-aux-request
?^ hem [%& u.hem]
~|(strange-path/q.pok !!)
::
++ as-magic-filename
^- (unit httr)
?+ [(fall p.pok %$) q.pok] ~
[?(%ico %png) %favicon ~]
:- ~
%^ resp 200 image//png
0w89wg.GV4jA.l9000.00dPb.YzBT6.giO00.o100d.wZcqc.a9tg-.VTG0b.
AUIvE.HBM3g.cK4SE.0aagi.l090p.I1P5g.Y-80r.y1YS9.1xE~Y.qgpFY.
vKN1V.905y0.2UwvL.43TUw.uL406.0-31h.xwoJF.Ul454.ilk00.00Yps.
BNumh.xpl9B.pS5Ji.i1BoC.ZAgg1.BsC5T.t6pLk.Thohn.gp000.0ov~P.
7M000.0o840.00010.0001i.h4x93.g0000.Eq2wR.7jB29
::
[%txt %robots ~]
:- ~
%^ resp 200 text//plain
%- role
:~ 'User-agent: *'
'Disallow: /'
==
==
::
++ as-beam
^- (unit beam)
|-
?~ q.pok
$(q.pok /index)
?. ((sane %tas) i.q.pok)
(tome q.pok)
`[[our i.q.pok da/now] (flop t.q.pok)]
::
++ as-aux-request :: /~/... req parser
^- (unit perk)
=. mef
?. ?=(%post mef) mef
?+ quy ~|(bad-quy/[req='"?PUT" or "?DELETE"' quy] !!)
~ mef
[[%'DELETE' ~] ~] %delt
[[%'PUT' ~] ~] %put
==
|-
?: ?=([%'~~' *] q.pok) :: auth shortcut
$(q.pok ['~' %as %own t.q.pok])
?. ?=([%'~' @ *] q.pok) ~
:- ~ ^- perk
=* pef i.t.q.pok
=+ but=t.t.q.pok :: XX =*
?+ pef ~|(pfix-lost/`path`/~/[pef] !!)
%debug ;;(perk [%bugs but])
%away [%away ~]
%at [%auth %at pok(q but)]
%am ?~(but !! [%auth %xen i.but pok(q t.but)])
%as
:+ %auth %get
~| bad-ship/?~(but ~ i.but)
?~ but !!
:_ pok(q t.but)
?+ i.but (slav %p i.but)
%anon anon
%own our
==
::
%on [%poll (raid but %uv ~)]
%of
:+ %view ?>(?=([@ ~] but) i.but)
?> ?=([[%poll @] ~] quy) :: XX eventsource
[~ (rash q.i.quy dem)]
::
%to
=- [%mess [- +<]:dir +>.dir (need-body (ot:jo xyro/some ~))]
^= dir
=+ ful=(read but %p %tas %tas ~)
?^ ful u.ful
~| bad-mess/but
[our (raid but %tas %tas ~)]
::
%in
~| expect/[%post 'application/json' /'@uv' '?PUT/DELETE']
?> &(?=(?(%delt %put) mef) ?=($|(~ [~ %json]) p.pok))
[%deps mef (raid but %uv ~)]
::
%is
?~ but
~|(no-app/but=but !!)
|- ^- perk
?~ p.pok $(p.pok [~ %json])
?. ?=(%json u.p.pok)
~|(is/stub/u.p.pok !!) :: XX marks
?: ((sane %tas) i.but)
$(but [(scot %p our) but])
?> ?=(?(%delt %put) mef)
[%subs mef [(slav %p i.but) (slav %tas -.t.but)] u.p.pok +.t.but]
::
%auth
:- %auth
|- ^- perk-auth
?+ p.pok !!
~ $(p.pok [~ %json])
[~ %js] [%js ~]
[~ %json]
?+ mef ~|(bad-meth/mef !!)
%get [%json ~]
2015-04-01 00:58:44 +03:00
%put
~| parsing/bod
[%try (need-body (ot ship/(su fed:ag) code/so ~):jo)]
::
%delt
~| parsing/bod
=+ jon=(need (poja q:(need bod)))
?> ?=(%o -.jon)
=+ 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
--
::
++ process
2015-03-04 05:22:02 +03:00
^- (each pest ,_done)
2015-03-28 04:06:38 +03:00
=+ pet=parse
?: ?=(%| -.pet)
2015-04-02 08:41:39 +03:00
[%& ~ p.pet]
2015-03-28 04:06:38 +03:00
(process-parsed p.pet)
::
++ process-parsed
|= hem=perk ^- (each pest ,_done)
2015-03-03 04:52:55 +03:00
?- -.hem
2015-03-28 04:06:38 +03:00
%auth (process-auth p.hem)
2015-04-02 08:41:39 +03:00
%away [%& %html logout-page:xml]
2015-03-28 04:06:38 +03:00
?(%beam %spur)
2015-03-04 05:22:02 +03:00
=+ ext=(fall p.pok %urb)
=+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem])
[%& %| ~ (ford-get-beam bem ext)]
2015-03-13 03:37:52 +03:00
::
2015-03-28 04:06:38 +03:00
%bugs
2015-03-27 04:01:28 +03:00
?- p.hem
2015-03-28 04:06:38 +03:00
%as (show-login-page)
2015-04-02 08:41:39 +03:00
%to [%& %html poke-test:xml]
2015-03-17 23:55:40 +03:00
==
2015-03-18 00:38:13 +03:00
::
2015-03-28 04:06:38 +03:00
%deps
=+ ire=(oryx-to-ixor (need-body to-oryx))
?> (~(has by wix) ire) :: XX made redundant by oryx checking
=< [%| (nice-json)]
2015-03-17 23:55:40 +03:00
?- p.hem
2015-03-28 04:06:38 +03:00
%put (new-dependency q.hem %| ire)
%delt done(liz (~(del ju liz) q.hem %| ire))
2015-03-17 23:55:40 +03:00
==
2015-03-13 03:37:52 +03:00
::
2015-03-17 23:55:40 +03:00
%mess
=+ cay=[%json !>(`json`r.hem)]
2015-04-02 08:41:39 +03:00
:+ %& %|
2015-03-17 23:55:40 +03:00
?: ?=(%json q.hem)
2015-04-02 08:41:39 +03:00
[~ [%g %mess [- + ~]:p.hem him cay]]
:- to//(scot %p him)/(scot %p p.p.hem)/[q.p.hem]
(ford-req [%cast q.hem %done ~ cay])
2015-03-28 04:06:38 +03:00
::
%poll
?. ?=([~ %js] p.pok) :: XX treat non-json cases?
[%| (new-dependency p.hem %& hen)]
=+ polling-url=['/' (apex:earn %| pok(u.p %json) quy)]
2015-04-02 08:41:39 +03:00
[%& %js (add-json (joba %poll (jape polling-url)) poll:js)]
2015-03-17 03:32:44 +03:00
::
%subs
2015-03-27 04:01:28 +03:00
?- p.hem
2015-03-28 04:06:38 +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
::
%view
~| lost-ixor/p.hem
2015-03-28 04:06:38 +03:00
[%| ((teba poll:(ire-ix p.hem)) u.q.hem)]
==
::
++ process-auth
|= ham=perk-auth ^- (each pest ,_done)
=+ yac=for-client
?- -.ham
2015-04-02 08:41:39 +03:00
%js [%& %js auth:js]
2015-03-28 04:06:38 +03:00
%json =^ jon ..ya stat-json.yac
[%| (give-json 200 ~ jon)]
%xen (show-login-page ~ ses.ham)
2015-03-13 03:37:52 +03:00
::
2015-03-28 04:06:38 +03:00
%at
=. ..ya abet.yac
=+ pez=process(pok p.ham)
?. ?=(%& -.pez) ~|(no-inject/p.ham !!)
2015-04-02 08:41:39 +03:00
?~ p.pez pez
2015-03-28 04:06:38 +03:00
?+ -.p.pez ~&(bad-inject/p.pez !!)
%red pez
2015-04-02 08:41:39 +03:00
%|
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]))]
2015-03-04 05:22:02 +03:00
::
2015-04-02 08:41:39 +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)))]
2015-03-03 04:52:55 +03:00
==
2015-03-28 04:06:38 +03:00
::
%del
=. ..ya (logoff:yac p.ham)
=+ cug=[(cat 3 cookie-prefix '=~; Path=/')]~
[%| (give-json 200 cug (joba %ok %b &))]
::
%get
~| aute/ham
?: |(=(anon him.ham) (~(has in aut.yac) him.ham))
2015-04-01 02:47:35 +03:00
%_ process
pok rem.ham
him him.ham
..ya abet.yac(him him.ham)
==
2015-03-28 04:06:38 +03:00
?. =(our him.ham)
2015-04-01 00:58:44 +03:00
[%| ((teba foreign-auth.yac) him.ham hat rem.ham quy)]
2015-03-28 04:06:38 +03:00
(show-login-page ~)
::
%try
~& ses-try/ses.yac
:- %|
?. =(our him.ham)
~|(stub-foreign/him.ham !!)
?. =(load-secret cod.ham)
~|(try/`@t`load-secret !!) :: XX security
2015-03-28 04:06:38 +03:00
=^ jon ..ya stat-json:(logon:yac him.ham)
(give-json 200 cug.yac jon)
2015-03-03 04:52:55 +03:00
==
2015-03-28 04:06:38 +03:00
::
++ show-login-page
2015-03-09 23:06:00 +03:00
|= ses=(unit hole) ^- (each pest ,_done)
2015-03-13 03:17:00 +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)
2015-03-09 23:06:00 +03:00
=. ..ya abet.yac
[%| (give-html 401 cug.yac login-page:xml)]
::
++ cookie-prefix (rsh 3 1 (scot %p our))
2015-03-28 04:06:38 +03:00
++ for-view ^+(ix (ire-ix (oryx-to-ixor (need-body to-oryx))))
::
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))))
~| bad-cookie/u.lig
=+ cyz=(~(got by wup) u.lig)
~(. ya u.lig cyz(cug ~))
2015-03-09 23:06:00 +03:00
::
2015-03-28 04:06:38 +03:00
++ new-ya |=(ses=hole ~(. ya ses (new-cyst ses)))
++ new-cyst
2015-03-09 23:06:00 +03:00
|= ses=hole
=* sec p.hat
=+ pef=cookie-prefix
2015-03-03 04:52:55 +03:00
^- cyst
:* ^- cred
:* hat(p sec)
~
2015-03-09 23:06:00 +03:00
'not-yet-implemented' ::(rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses))))
2015-03-03 04:52:55 +03:00
::
=+ lag=(~(get by maf) %accept-language)
?~(lag ~ ?~(u.lag ~ [~ i.u.lag]))
::
cip
~
==
[anon ~]
::
:_ ~
%^ cat 3
(cat 3 (cat 3 pef '=') ses)
:: (cat 3 '; HttpOnly' ?.(sec '' '; Secure'))
'; Path=/; HttpOnly'
::
now
~
2015-03-09 23:06:00 +03:00
~
2015-03-03 04:52:55 +03:00
:: [1 ~]
==
--
2015-03-17 03:32:44 +03:00
::
2015-03-18 00:38:13 +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-03-04 05:22:02 +03:00
=| [ses=hole cyst]
=* 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
|= [him=ship pul=purl] ^+ ..ya
=. way (~(put by way) him pul hen)
(ames-gram:abet him [lon/~ ses])
::
++ foreign-hat
|= [him=ship hat=hart] ^+ ..ya
~| 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]
==
=+ url=(welp (earn pul(p hat)) '#' (head:earn p.pul))
%- give-thou:abet
(add-cookies cug [307 [location/(crip url)]~ ~])
::
2015-03-09 23:06:00 +03:00
++ logon
|= her=ship
%_ +>
him her
aut (~(put in aut) her)
..ya
~& logon/[our her ses]
?. =(our her)
..ya
=+ sap=(~(get by sop) ses)
~& sap
?. ?=([~ @ %|] sap)
..ya
(ames-gram -.u.sap aut/~ ses)
==
2015-03-04 05:22:02 +03:00
++ logoff
|= her=(unit ship) ^+ ..ya
?~ her abut
=. aut (~(del in aut) u.her)
?~ aut abut
abet(him ?.(=(her him) him n.aut))
::
2015-04-01 02:47:35 +03:00
++ fcgi-cred %_(ced aut (~(put ju aut.ced) %$ (scot %p him)))
2015-03-04 05:22:02 +03:00
++ stat-json
^+ [*json ..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-03-18 00:38:13 +03:00
=+ ire=(oryx-to-ixor orx)
2015-03-27 04:01:28 +03:00
=. wix (~(put by wix) ire [him ~ now [1 ~] ~ ~])
2015-03-04 05:22:02 +03:00
:_ abet
%- jobe :~
oryx/s/orx
2015-03-17 03:32:44 +03:00
ixor/s/ire
2015-03-04 05:22:02 +03:00
ship/(jape +:<our>)
user/(jape +:<him>)
auth/a/(turn (~(tap in aut)) |=(a=@p (jape +:<a>)))
==
2014-03-12 23:50:39 +04:00
--
2015-03-17 03:32:44 +03:00
::
++ ix
=| [ire=ixor stem]
=* sem ->
|%
++ abet ..ix(wix (~(put by wix) ire sem))
2015-03-28 04:06:38 +03:00
++ done .
2015-03-19 03:22:20 +03:00
++ give-json (teba ^give-json)
2015-03-17 03:32:44 +03:00
++ pass-note (teba ^pass-note)
2015-03-28 04:06:38 +03:00
++ teba |*(a=$+(* ..ix) |*(b=* %_(done ..ix (a b))))
2015-03-17 03:32:44 +03:00
::
2015-03-28 04:06:38 +03:00
++ add-even
|= a=even ^+ eve
[+(p.eve) (~(put by q.eve) p.eve a)]
2015-03-17 03:32:44 +03:00
::
2015-03-27 04:01:28 +03:00
++ add-subs
|= [a=hasp %json b=path] ^+ ..ix
=: sud (~(put by sud) [a b] hen)
dus (~(put by dus) hen [a b])
==
abet:(pass-note of//[ire] [%g %show [- + ~]:a him b])
::
++ del-subs
|= [a=hasp %json b=path] ^+ ..ix
=. hen (~(got by sud) [a b])
=: sud (~(del by sud) [a b] hen)
dus (~(del by dus) hen [a b])
==
abet:(pass-note of//[ire] [%g %nuke [- + ~]:a him])
::
2015-03-17 03:32:44 +03:00
++ get-rush
2015-03-27 04:01:28 +03:00
|= a=json ^+ ..ix
(get-even [%rush (~(got by dus) hen) (joba %json a)])
2015-03-17 23:55:40 +03:00
::
2015-03-27 04:01:28 +03:00
++ get-mean |=(a=ares (get-even [%mean (~(got by dus) hen) a]))
2015-03-17 23:55:40 +03:00
++ get-even
|= 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-03-27 02:29:17 +03:00
:: ~& got-even/ude
2015-03-19 03:22:20 +03:00
(give-even(hen p.u.ude, ude ~) q.u.ude num ven)
2015-03-17 03:32:44 +03:00
::
2015-03-19 03:22:20 +03:00
++ give-even
|= [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-03-27 04:01:28 +03:00
mow ?.(?=(%rush -.ven) mow mow:(pass-took p.ven))
2015-03-27 02:29:17 +03:00
==
2015-03-19 03:22:20 +03:00
?> pol :: XX eventstream
%^ give-json 200 ~
%^ jobe id/(jone num) type/[%s -.ven]
?- -.ven
%news ~[from/[%s (scot %uv p.ven)]]
2015-03-20 02:35:10 +03:00
%rush ~[from/(subs-to-json p.ven) data/q.ven]
%mean ~[from/(subs-to-json p.ven) data/(ares-to-json q.ven)]
2015-03-19 03:22:20 +03:00
==
::
2015-03-28 04:06:38 +03:00
++ pass-took
|= a=[p=hasp path]
=. hen (~(got by sud) a)
(pass-note of//[ire] [%g %took [- + ~]:p.a him])
::
++ poll
|= a=@u ^+ ..ix
?: =(a p.eve)
=. +>
?^ ude ~&(e/ix/wait/%replaced done)
wait-era(era (add ~s30 now))
:: ~& ude-wait/hen
abet(ude [~ hen &])
?: (gth a p.eve) ~|(seq-high/cur=p.eve !!)
=+ ven=~|(seq-low/cur=p.eve (~(got by q.eve) a))
abet:(give-even & a ven)
::
2015-03-20 02:35:10 +03:00
++ subs-to-json
|= [a=hasp b=path]
%- jobe :~
ship/[%s (rsh 3 1 (scot %p p.a))]
appl/[%s q.a]
path/(jape (spud b))
==
2015-03-19 03:22:20 +03:00
::
2015-03-17 03:32:44 +03:00
++ wait-era (pass-note of//[ire] [%t %wait era])
++ wake ^+(..ix abet(ude ~)) :: XX other effects?
2015-03-28 04:06:38 +03:00
:: XX unused
++ print-subs |=([a=hasp 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 -
2014-05-31 23:40:02 +04:00
|= [now=@da eny=@ ski=sled] :: activate
2014-03-12 23:50:39 +04:00
^? :: opaque core
|% ::
2014-06-04 14:40:09 +04:00
++ call :: handle request
|= $: hen=duct
2014-06-04 21:56:30 +04:00
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
?: ?=(%soft -.q.hic)
((hard kiss) p.q.hic)
?: (~(nest ut -:!>(*kiss)) | p.hic) q.hic
~& [%eyre-call-flub (,@tas `*`-.q.hic)]
((hard kiss) q.hic)
==
2014-05-31 23:40:02 +04:00
^- [p=(list move) q=_..^$]
2015-02-27 00:23:46 +03:00
=+ our=`@p`0x100 :: XX sentinel
2014-05-31 23:40:02 +04:00
=+ ska=(slod ski)
2014-05-02 03:33:15 +04:00
=+ sky=|=(* `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a]))))
=. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need
2014-05-31 23:40:02 +04:00
^- [p=(list move) q=_..^$]
2014-03-20 05:05:42 +04: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
2013-12-15 09:42:27 +04:00
|= [now=@da hen=duct]
2013-09-29 00:21:18 +04:00
^- (unit ,@da)
~
::
2015-02-27 03:04:12 +03:00
++ load :: clam previous state
2015-03-27 01:32:32 +03:00
|= old=bolo ::_[.(wix **)]:*bolo
2014-05-31 23:40:02 +04:00
^+ ..^$
2015-03-27 01:32:32 +03:00
..^$(+>- old) ::(wix ~))
2013-09-29 00:21:18 +04:00
::
++ scry
2014-05-27 00:43:40 +04:00
|= [our=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path]
^- (unit (unit (pair mark ,*)))
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
2014-10-04 02:32:10 +04:00
|= [tea=wire hen=duct hin=(hypo sine)]
2014-06-04 14:40:09 +04:00
^- [p=(list move) q=_..^$]
2014-10-04 02:32:10 +04:00
?: ?=(%veer +<.q.hin) :: vomit
[[hen %give +.q.hin]~ ..^$]
?: ?=(%vega +<.q.hin) :: vomit
[[hen %give +.q.hin]~ ..^$]
2015-02-27 00:23:46 +03:00
=+ our=`@p`0x100 :: XX sentinel
2014-06-04 14:40:09 +04:00
=+ ska=(slod ski)
=+ sky=|=(* `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a]))))
=. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need
^- [p=(list move) q=_..^$]
=. 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
--