shrub/arvo/jael.hoon

147 lines
4.8 KiB
Plaintext
Raw Normal View History

2014-09-23 21:11:59 +04:00
:: %jael, secret storage
::
2015-12-21 00:16:39 +03:00
:::: /hoon+jael
2014-09-23 21:11:59 +04:00
::
!? 164
::::
2014-11-02 01:13:18 +03:00
:: %jael is logically homogeneous, but please follow these conventions:
::
:: /cap :: foreign app keys
2014-12-17 02:46:12 +03:00
:: /service :: service name, eg %face for FB
2014-11-02 01:13:18 +03:00
:: /appid :: your ship's app-id
:: /@uvH :: by hash
:: /@ud :: by number
:: /@tas :: by name
::
:: /key :: foreign user secrets
:: /service :: service name, eg %face
:: /userid :: user identity
2014-11-04 02:07:46 +03:00
::
:: /urb :: urbit secrets
2015-12-21 00:16:39 +03:00
:: /tok+hash
2014-11-02 01:13:18 +03:00
2014-09-23 21:11:59 +04:00
|= pit=vase
=> =~
:: structures
|%
++ axle :: %jael state
2014-12-17 02:46:12 +03:00
$: %0 :: %jael version
2014-11-08 13:08:29 +03:00
ent=@ :: entropy
sef=safe :: secret tree
red=(map duct (set path)) :: reverse subscribers
2014-09-23 21:11:59 +04:00
== ::
++ gift :: out result <-$
2014-11-08 13:08:29 +03:00
$% [%dead p=path] :: key expired
[%live p=path q=@] :: key created
2014-09-23 21:11:59 +04:00
== ::
++ kiss :: in request ->$
2014-11-08 13:08:29 +03:00
$% [%kill p=path] :: discard secret
2014-12-17 02:46:12 +03:00
[%make p=@uw q=(unit ,@da) r=@ud s=path] :: generate random
2014-11-08 13:08:29 +03:00
[%nuke ~] :: erase subscriber
[%tell p=@uw q=(unit ,@da) r=path] :: save secret
2014-09-23 21:11:59 +04:00
== ::
2014-12-17 02:46:12 +03:00
++ move ,[p=duct q=(mold note gift)] :: typed move
++ note :: out request $->
$% $: %b :: to %behn
2014-12-17 02:46:12 +03:00
$% [%wait p=@da] ::
[%rest p=@da] ::
== == == ::
2014-11-08 13:08:29 +03:00
++ perm (pair ,@ud (list ,@ud)) :: prime definition
++ safe ::
2014-12-17 02:46:12 +03:00
$: nub=(unit ,@uw) :: secret
2014-11-08 13:08:29 +03:00
dex=(unit ,@da) :: expiration
sud=(set duct) :: subscribers
2014-12-17 02:46:12 +03:00
kin=(map term safe) :: children
2014-11-08 13:08:29 +03:00
== ::
2014-09-23 21:11:59 +04:00
-- ::
2014-12-17 02:46:12 +03:00
:: programs
|%
++ bu
|_ $: xap=path
fes=(list safe)
moz=(list move)
==
axle
::
++ bu-abet :: resolve
^- axle
?~ xap +<+
%= bu-abet
xap t.xap
fes t.fes
sef %= i.fes
kin
?: =(*safe sef)
(~(del by kin.i.fes) i.xap)
(~(put by kin.i.fes) i.xap sef)
==
==
::
++ bu-kill :: destroy
^+ .
=+ dus=(~(tap by
::
++ bu-ajar :: descend
|= pax=path
^+ +>
?~ pax +>.$
%= $
pax t.pax
xap [i.pax xap]
fes [sef fes]
sef (fall (~(get by kin.sef) i.pax) *safe)
==
--
++ bury
|= [pax=path lex=axle]
(~(bu-ajar bu [~ ~ ~] tof.lex lex) pax)
--
2014-09-23 21:11:59 +04:00
. ==
=| axle
|= [now=@da eny=@ ski=sled] :: activate
^? :: opaque core
|% ::
++ call :: request
|= [hen=duct hic=(hypo (hobo kiss))]
^- [p=(list move) q=_..^$]
=> .(q.hic ?.(?=(%soft -.q.hic) q.hic ((hard kiss) p.q.hic)))
2014-12-17 02:46:12 +03:00
=^ moz +>+>-
=< bu-abet
?- -.p.q.hic
%kill
kill:(bury p.p.q.hic +>+>-)
::
%make
%nuke
%tell
==
2014-09-23 21:11:59 +04:00
::
++ doze
|= [now=@da hen=duct]
^- (unit ,@da)
~
::
++ load :: highly forgiving
|= old=*
=+ lox=((soft axle) old)
^+ ..^$
?~ lox
~& %jael-reset
..^$
..^$(+>- u.lox)
::
++ scry
|= [fur=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path]
^- (unit (unit (pair mark ,*)))
:: actually scry
~
::
2015-12-21 00:16:39 +03:00
++ stay :: save w+o cache
2014-09-23 21:11:59 +04:00
`axle`+>-.$(pol (~(run by pol) |=(a=baby [tad.a dym.a ~])))
::
++ take :: response
|= [tea=wire hen=duct hin=(hypo noun)]
!!
--