Skip to main content

Delegation chain

The chain of actors behind a token: the person, the agent that acts for the person, and each sub-agent after it.

PatternReadyView source
Works with
Reactshadcn/ui
Runs on sample data, with the neutral theme of shadcn/ui.

A small diagram for audit views and for "How this works" panels. It shows the person on whose behalf the work is done, then each agent in the order in which it received the work.

Installation​

The command adds the file to your project, with the shadcn/ui components that it uses. Your project needs shadcn/ui.

pnpm dlx shadcn@latest add https://examples.lumoauth.dev/r/delegation-chain.json

Usage​

Build the chain yourself, or read it from a token with chainFromToken.

app/audit/chain.tsx
import { DelegationChain, chainFromToken } from '@/components/delegation-chain';

export function Chain({ token }: { token: string }) {
const chain = chainFromToken(token);
if (!chain) return null;
return <DelegationChain chain={chain} maxDepth={5} />;
}

chainFromToken reads the token and does not check its signature. Verify the token on your server first, with verifyAccessToken() of @lumoauth/agent.

The act claim of a token names the caller, and each nested act names the actor before it. The pattern turns that order around, so the chain reads from the person to the caller. To show names in place of IDs, set label on the subject and on each actor.

Where the data comes from​

What the pattern showsCall
The chain of a tokenThe sub and the nested act claim of the access token
The same, with the SDKDelegationModule.parseActorChain(token), DelegationModule.getSubject(token)
Create a link of the chaindelegation.exchange(), delegation.delegateToSubAgent()

States​

Runs on sample data, with the neutral theme of shadcn/ui.
  • No delegation. The subject made the call directly.
  • From a token. The middle chain is read from a token with a nested act claim.
  • At the largest length. With maxDepth, the last step says that it cannot hand the work on.

Props​

PropTypeDescription
chainrequiredDelegationChainDataThe subject and the actors.
maxDepthnumberThe largest number of actors that a chain may have.
classNamestringClass name for the list.

DelegationChainData​

OptionTypeDescription
subjectrequired{ id: string; label?: string }The person or the service on whose behalf the work is done.
actorsrequiredChainActor[]The actors in the order in which they received the work. Each has id, label and scopes.