Documentation
    Preparing search index...

    Function check

    • Check whether an identity has a specific capability.

      Decision logic:

      1. If identity has no entry: return based on defaultPolicy
        • 'permissive' → true (all caps granted to unknown identities)
        • 'restrictive' → false (all caps denied to unknown identities)
      2. If identity is blocked: return false (blocked overrides all caps)
      3. Otherwise: return (entry.caps & cap) !== 0

      Parameters

      • state: AclState

        Current ACL state (immutable)

      • identity: Identity

        Napplet identity to check

      • cap: number

        Capability bit constant (e.g., CAP_RELAY_READ)

      Returns boolean

      true if the identity has the capability, false otherwise

      import { check, createState, grant } from '@kehto/acl';
      import { CAP_RELAY_READ } from '@kehto/acl';

      const state = createState('restrictive');
      const id = { dTag: 'chat', hash: 'ff00' };

      check(state, id, CAP_RELAY_READ); // false (restrictive, no entry)

      const state2 = grant(state, id, CAP_RELAY_READ);
      check(state2, id, CAP_RELAY_READ); // true