Type Parameters

Hierarchy

Methods

  • Creates new capability group containing capabilities from this group and provided other capability. This method complements and method on Capability to allow chaining e.g. read.and(write).and(modify).

    Type Parameters

    Parameters

    Returns CapabilitiesParser<[...M[], W]>

  • 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, Amplify<M>>>

  • Parameters

    Returns Select<Amplify<M>>

Generated using TypeDoc