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
const verify = capability({
can: "account/verify",
with: URI({ protocol: "mailto:" })
derives: ({ with: url }, from) =>
url.href.startsWith(from.with.href) ||
new Failure(`${url.href} is not contained in ${from.with.href}`)
})
// derive registration capability from email verification
const register = validate.derive({
to: capability({
can: "account/register",
with: URI({ protocol: "mailto:" }),
derives: ({ with: url }, from) =>
url.href.startsWith(from.with.href) ||
new Failure(`${url.href} is not contained in ${from.with.href}`)
}),
derives: (registered, verified) =>
registered.with.href === verified.with.href ||
new Failure(`Registration email ${registered.pathname} does not match verified email ${verified.with.pathname}`)
})
Generated using TypeDoc
Creates new capability group containing capabilities from this group and provedid
othercapability. This method complementsandmethod onCapabilityto allow chaining e.g.read.and(write).and(modify).