Documentation
    Preparing search index...

    Function createEnforceGate

    • Create an enforcement gate with the given configuration.

      Returns a function that checks a single capability for a given pubkey. Every call is logged to the audit callback.

      Parameters

      • config: EnforceConfig

        Enforcement configuration with ACL checker, identity resolver, and audit hooks

      Returns (
          pubkey: string,
          capability:
              | "relay:read"
              | "relay:write"
              | "cache:read"
              | "cache:write"
              | "hotkey:forward"
              | "state:read"
              | "state:write"
              | "identity:read"
              | "keys:bind"
              | "keys:forward"
              | "media:control"
              | "notify:send"
              | "notify:channel"
              | "theme:read"
              | "config:read"
              | "resource:fetch"
              | "cvm:call"
              | "outbox:read"
              | "outbox:write"
              | "upload:write"
              | "intent:read"
              | "intent:write",
          message?: unknown[],
      ) => EnforceResult

      An enforce function that checks capabilities and logs decisions

      const gate = createEnforceGate({
      checkAcl: aclStore.check,
      resolveIdentity: (pk) => nappKeyRegistry.getEntry(pk),
      onAclCheck: hooks.onAclCheck,
      });
      const result = gate('abc123...', 'relay:write');
      // result.allowed === true | false