Defined a derived capability which can be delegated from this capability.
For example if you define "account/validate" capability and derive
"account/register" capability from it when validating claimed
"account/register" capability it could be proved with either
"account/register" delegation or "account/validate" delegation.
// capability issued by account verification service on email validation constverify=capability({ can:"account/verify", with:URI({ protocol:"mailto:" }) derives: ({ with: url }, from) => url.href.startsWith(from.with.href) || newFailure(`${url.href} is not contained in ${from.with.href}`) })
// derive registration capability from email verification constregister=validate.derive({ to:capability({ can:"account/register", with:URI({ protocol:"mailto:" }), derives: ({ with: url }, from) => url.href.startsWith(from.with.href) || newFailure(`${url.href} is not contained in ${from.with.href}`) }), derives: (registered, verified) => registered.with.href===verified.with.href|| newFailure(`Registration email ${registered.pathname} does not match verified email ${verified.with.pathname}`) })
Defined a derived capability which can be delegated from
this
capability. For example if you define"account/validate"
capability and derive"account/register"
capability from it when validating claimed"account/register"
capability it could be proved with either "account/register" delegation or "account/validate" delegation.