Type Parameters

Hierarchy

Methods

  • 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}`)
    })

    Type Parameters

    Parameters

    Returns TheCapabilityParser<DerivedMatch<T, M>>

  • Parameters

    Returns MatchResult<M>

  • Parameters

    Returns Select<M>

Generated using TypeDoc