attenuate-entity-ref as well as attenuate-sturdy

This commit is contained in:
Tony Garnock-Jones 2021-06-08 09:21:54 +02:00
parent 1290e30c3d
commit da0d2b8e61
3 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,7 @@
(rename-out [make-entity entity])
(struct-out entity-ref)
attenuate-entity-ref
parse-Ref
Ref->preserves
@ -432,3 +433,11 @@
(define (deliver maybe-proc . args)
(when maybe-proc
(apply maybe-proc args)))
;; TODO: prove to myself I've gotten the order correct. (Right-to-left, wasn't it?!?!)
(define (attenuate-entity-ref r . caveats)
(if (null? caveats)
r
(match r
[(entity-ref relay target previous-attenuation)
(entity-ref relay target (append previous-attenuation caveats))])))

View File

@ -90,6 +90,7 @@
[(Caveat-Rewrite r)
(rewrite r v)]))
;; TODO: prove to myself I've gotten the order correct. (Right-to-left, wasn't it?!?!)
(define (run-rewrites attenuation v)
(let loop ((stages attenuation) (v v))
(match stages

View File

@ -15,7 +15,7 @@
sturdy-encode
sturdy-decode
mint
attenuate
attenuate-sturdy
SturdyRef-valid?
validate
(all-from-out "schemas/gen/sturdy.rkt"))
@ -47,7 +47,7 @@
(define (mint oid key)
(SturdyRef oid '() (hmac-sha256 key (sturdy-encode oid))))
(define (attenuate r . attenuation)
(define (attenuate-sturdy r . attenuation)
(match-define (SturdyRef oid caveatChain sig) r)
(SturdyRef oid
(append caveatChain (list attenuation))