npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lyhna/gate

v0.1.0

Published

Express adapter for Lyhna's bind() authority boundary.

Downloads

61

Readme

@lyhna/gate

Express adapter for Lyhna's bind() authority boundary. Every request goes through Lyhna's enforcement core before your handler runs. Approved requests continue; refused and escalated requests are blocked with a structured receipt.

Install

npm install @lyhna/gate

Set your API key in the environment:

export LYHNA_API_KEY=sk-...

Usage

import express from 'express';
import { lyhnaGate } from '@lyhna/gate';

const app = express();
app.use(express.json());

app.post(
  '/api/transfer',
  lyhnaGate({
    action_type: 'financial_transfer',
    intent: 'initiate_transfer',
    intent_version: 'v1',
    payloadFrom: (req) => ({
      amount: req.body.amount,
      recipient: req.body.recipient,
    }),
  }),
  (req, res) => {
    // Only reached when Lyhna returns APPROVED
    const receipt = req.lyhna_receipt;
    res.json({ ok: true, receipt_id: receipt?.receipt_id });
  },
);

Configuration

| Field | Type | Required | Description | |---|---|---|---| | action_type | string | Yes | Canonical action identifier registered with Lyhna | | intent | string | Yes | Intent name for this bind call | | intent_version | string | Yes | Intent version string (e.g. "v1") | | payloadFrom | (req) => Record<string, unknown> | Yes | Synchronous function that extracts the action payload from the request | | attachAs | string | No | Key to attach the receipt on req. Defaults to "lyhna_receipt" |

The adapter does not accept apiKey or baseUrl. Key and endpoint are read from environment variables by @lyhna/bind:

| Env var | Default | Description | |---|---|---| | LYHNA_API_KEY | — | Required. Your tenant API key | | LYHNA_ENDPOINT | https://api.lyhna.com | Optional. Override the enforcement core URL |

Response envelopes

APPROVED — your route handler runs; req.lyhna_receipt contains the full LyhnaReceiptV2.

REFUSED (403):

{
  "outcome": "REFUSED",
  "execution": "blocked_refused",
  "receipt": { "...": "..." },
  "reason": "Action refused by Lyhna governance policy",
  "escalate_to": null
}

ESCALATED (202):

{
  "outcome": "ESCALATED",
  "execution": "blocked_pending_authority",
  "receipt": { "...": "..." },
  "reason": "Higher authority required",
  "escalate_to": "human_governor"
}

GATE_ERROR (503) — configuration or transport failure:

{
  "outcome": "GATE_ERROR",
  "execution": "blocked_gate_error",
  "receipt": null,
  "reason": "gate_transport_unavailable",
  "escalate_to": null
}

TypeScript

The req.lyhna_receipt type is automatically augmented on Express.Request:

import type { LyhnaReceiptV2 } from '@lyhna/gate';
// or directly from @lyhna/bind

Links