From 2d031fdbdb374426bb4e1c493073f88d88637938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 26 Feb 2025 19:07:10 +0100 Subject: [PATCH] exectx: easy access to the root delegation --- toolkit/server/exectx/ucanctx.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/toolkit/server/exectx/ucanctx.go b/toolkit/server/exectx/ucanctx.go index cc9ae9e..5bb1f9e 100644 --- a/toolkit/server/exectx/ucanctx.go +++ b/toolkit/server/exectx/ucanctx.go @@ -92,6 +92,13 @@ func (ctn *UcanCtx) GetDelegation(cid cid.Cid) (*delegation.Token, error) { return nil, delegation.ErrDelegationNotFound } +// GetRootDelegation returns the delegation.Token at the root of the proof chain. +func (ctn *UcanCtx) GetRootDelegation() *delegation.Token { + proofs := ctn.inv.Proof() + c := proofs[len(proofs)-1] + return ctn.dlgs[c] +} + // Policies return the full set of policy statements to satisfy. func (ctn *UcanCtx) Policies() policy.Policy { return ctn.policies