# We will create a TCP listener on port 9222, which speaks unencrypted # protocol and allows interaction with the default/system gatekeeper, which # has a single noise binding for introducing encrypted interaction with a # *second* gatekeeper, which finally allows resolution of references to # other objects. # First, build a space where we place bindings for the inner gatekeeper to # expose. let ?inner-bindings = dataspace # Next, start the inner gatekeeper. > ? ?inner-gatekeeper> [ # Expose it via a noise binding at the outer/system gatekeeper. $inner-gatekeeper #f> ] # Now, expose the outer gatekeeper to the world, via TCP. The system # gatekeeper is a primordial syndicate-server object bound to $gatekeeper. $gatekeeper>> # Finally, let's expose some behaviour accessible via the inner gatekeeper. # # We will create a service dataspace called $world. let ?world = dataspace # Running `syndicate-macaroon mint --oid a-service --phrase hello` yields: # # # # That's a root capability for the service. We use the corresponding # sturdy.SturdyDescriptionDetail to bind it to $world. # $inner-bindings += $world #f> # Now, we can hand out paths to our services involving an initial noise # step and a subsequent sturdyref/macaroon step. # # For example, running `syndicate-macaroon` like this: # # syndicate-macaroon mint --oid a-service --phrase hello \ # --caveat '> ]>>' # # generates # # > , ]>>], # oid: a-service, # sig: #[CXn7+rAoO3Xr6Y6Laap3OA]}> # # which is an attenuation of the root capability we bound that wraps all # assertions and messages in a `` wrapper. # # All together, the `gatekeeper.Route` that Alice would use would be # something like: # # ] # # > , ]>>], # oid: a-service, # sig: #[CXn7+rAoO3Xr6Y6Laap3OA] }>> # # Here's one for "bob": # # syndicate-macaroon mint --oid a-service --phrase hello \ # --caveat '> ]>>' # # > , ]>>], # oid: a-service, # sig: #[/75BbF77LOiqNcvpzNHf0g]}> # # ] # # > , ]>>], # oid: a-service, # sig: #[/75BbF77LOiqNcvpzNHf0g] }>> # # We relay labelled to unlabelled information, enacting a chat protocol # that enforces usernames. $world [ # Assertions of presence have the username wiped out and replaced with the label. ? > # Likewise utterance messages. ?? > ! # We allow anyone to subscribe to presence and utterances. ? ?o>> $o> ? ?o>> $o> ] # We can also use sturdyref rewrites to directly handle `Says` and # `Present` values, rather than wrapping with `` and # unwrapping using the script fragment just above. # # The multiply-quoted patterns in the `Observe` cases start to get unwieldy # at this point! # # For Alice: # # syndicate-macaroon mint --oid a-service --phrase hello --caveat ']> ]>> # ]> ]>> # <_>]> <_>]>> > # <_>]> <_>]>> > # ]>' # # ]> ]>> # , ]> , ]>> # , <_>]>, <_>]>> > # , <_>]>, <_>]>> > ]>]}> # # ] # # ]> ]>> # , ]> , ]>> # , <_>]>, <_>]>> > # , <_>]>, <_>]>> > ]>]}>> # # For Bob: # # syndicate-macaroon mint --oid a-service --phrase hello --caveat ']> ]>> # ]> ]>> # <_>]> <_>]>> > # <_>]> <_>]>> > # ]>' # # ]> ]>> # , ]> , ]>> # , <_>]>, <_>]>> > # , <_>]>, <_>]>> > ]>]}> # # ] # # ]> ]>> # , ]> , ]>> # , <_>]>, <_>]>> > # , <_>]>, <_>]>> > ]>]}>>