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

@ailuntz/resource-agent

v1.1.1

Published

Authenticated S3 download links and elastic Cloudflare tunnel workers

Readme

@ailuntz/resource-agent

Authenticated short-lived S3 download links, with health-aware Cloudflare Tunnel selection and elastic connector workers. Clients receive one link; object data travels through the selected tunnel, without passing through the application backend.

npm install @ailuntz/[email protected]

Backend integration:

import { signedRequest } from '@ailuntz/resource-agent/client';
const request = await signedRequest({
  clientId: 'shop', secret: process.env.DOWNLOAD_CLIENT_SECRET,
  path: '/v1/downloads',
  body: { bucket: 'shop-files', key: 'resources/example.zip',
    filename: 'example.zip', expiresAt: Date.now() + 120000 },
});
const result = await fetch(process.env.DOWNLOAD_AGENT_URL + '/v1/downloads', request);

Authenticate the user and check resource access on your backend before making this request. Never distribute the client secret or storage signing key to browsers.

Runtime

Run resource-agent serve --runtime /runtime and resource-agent channels --runtime /runtime as separate supervised services. There is no native service installer.

  • secrets/agent.json: S3 read-only signing credentials and per-client shared secrets/bucket allowlists.
  • channels.json: four pre-provisioned tunnel definitions; first channel id primary.
  • channel-policy.json: minimum/maximum channels, scaling and draining intervals.
  • state/: shared writable health snapshots and admission markers.
  • AILUNTZ_CONFIG_DIR: optional directory holding channel definitions/policy.
  • CLOUDFLARED_BIN: path to a pinned cloudflared executable. In containers, AILUNTZ_CONTAINER=1 sends worker output to container logs.

The primary tunnel and control tunnel run separately. The channel manager starts/stops additional cloudflared processes in its own container, without host process control or a Docker socket. Shared networking gives these workers access to the download gateway; shared state lets the gateway stop issuing new links before a lane drains.

HTTP API

| Route | Purpose | |---|---| | GET /healthz | Liveness only | | POST /v1/downloads | Signed GET link; maximum 120 seconds, bounded by authorization expiry | | POST /v1/objects/stat | Authorized object size lookup |

serve binds to loopback port 19081. Signatures bind the caller, method, path, timestamp, nonce and body. Nonces cannot be reused within the process. Requests with a browser Origin, disallowed bucket, invalid path or expired grant are rejected. Restarting clears replay memory; the original authorization deadline still applies.

Scaling preserves existing transfers: stop issuing links, wait at least 150 seconds, and require zero observed in-flight requests before stopping a worker. Missing metrics never permit draining. New requests try healthy lanes after a failure; an interrupted download needs a new URL and a client that supports Range resumption. Multiple tunnels share the same physical uplink.

The package contains code only: no deployment credentials, tunnel tokens, customer objects or production host configuration. The Docker image ailuntz/resource-agent:1.1.1 installs this exact npm release and a pinned official cloudflared binary.