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

@ankitpandey2708/envguard

v1.1.3

Published

Validate third-party API keys at deploy time — fail fast before bad keys reach production

Readme

npm version npm downloads License: MIT Node.js >=20 Ask DeepWiki

envguard — API Key Validator for CI/CD Deployments

envguard is a Node.js CLI and library that validates third-party API keys at deploy time. It makes a live request to each provider and fails your build immediately if a key is revoked, missing, or has the wrong permissions — before bad keys ever reach production.

Why envguard?

Most tools only check if an API key exists. They can't tell you if the key is actually valid.

✓ Key exists          ← dotenv, envalid, t3-env stop here
✗ Key is revoked      ← envguard catches this
✗ Key has wrong scope ← envguard catches this

| Feature | envguard | envalid | t3-env | dotenv-safe | |---|---|---|---|---| | Checks key actually works | ✅ | ❌ | ❌ | ❌ | | Detects revoked keys | ✅ | ❌ | ❌ | ❌ | | Detects wrong permissions | ✅ | ❌ | ❌ | ❌ | | Auto-detect keys from .env | ✅ | ❌ | ❌ | ❌ | | CLI + programmatic API | ✅ | ❌ | ❌ | ❌ | | CI/CD integration | ✅ | ✅ | ✅ | ✅ | | TypeScript types | ✅ | ✅ | ✅ | ❌ |

Getting Started

1. Install

npm install @ankitpandey2708/envguard --save-dev

A postinstall hook automatically adds envguard validate to your build script.

2. Generate config

npx envguard init --api-key YOUR_OPENROUTER_API_KEY

Scans .env files, detects API keys via AI, and writes envguard.json. Requires a free OpenRouter key from https://openrouter.ai/keys.

On re-run, only new env vars are sent to the LLM — already-configured keys are skipped.

First run:

Found 3 API key(s):
  OPENAI_API_KEY → openai
  STRIPE_SECRET_KEY → stripe
  ANTHROPIC_API_KEY → anthropic

Created envguard.json

Re-run (nothing changed):

No new env vars to add — envguard.json is up to date.

3. Validate

envguard validate
✔ STRIPE_SECRET_KEY (Stripe): OK
✖ OPENAI_API_KEY (OpenAI): INVALID
! GEMINI_API_KEY (Google Gemini): MISSING (optional)

Deployment blocked: 1 required key failed.

CLI Reference

envguard init

Scans .env files and generates or updates envguard.json.

| Flag | Description | |---|---| | --api-key <key> | OpenRouter API key (or set OPENROUTER_API_KEY) | | --model <id> | OpenRouter model (or set OPENROUTER_MODEL; default: openrouter/free) | | --config <path> | Write config to a custom path |

envguard validate

Validates all keys in envguard.json against their live provider APIs.

| Flag | Description | |---|---| | --config <path> | Use a different config file | | --provider <id> | Check only one provider | | --fail-fast | Stop after first required key failure | | --json | Machine-readable JSON output | | -h, --help | Show help |

Exit codes:

| Code | Meaning | |---|---| | 0 | All required keys valid | | 1 | Validation failed | | 2 | Config or internal error |

Status meanings:

| Status | Meaning | |---|---| | OK | Key is valid and working | | INVALID | Key was rejected (revoked or wrong scope) | | MISSING | Environment variable not set | | DENIED | Key lacks required permissions | | UNKNOWN | Network error or provider issue |

JSON output:

envguard validate --json
{
  "ok": false,
  "passed": [
    { "envVar": "STRIPE_SECRET_KEY", "provider": "Stripe", "status": "ok", "required": true }
  ],
  "failed": [
    { "envVar": "OPENAI_API_KEY", "provider": "OpenAI", "status": "invalid", "required": true }
  ],
  "warnings": []
}

Config Reference

envguard.json schema:

{
  "concurrency": 5,
  "keys": [
    { "envVar": "OPENAI_API_KEY", "provider": "openai" },
    { "envVar": "STRIPE_SECRET_KEY", "provider": "stripe" },
    { "envVar": "TWILIO_AUTH_TOKEN", "provider": "twilio", "required": false }
  ]
}

| Field | Description | Default | |---|---|---| | concurrency | Parallel checks to run | 5 | | keys[].envVar | Environment variable name | — | | keys[].provider | Provider ID (see table below) | — | | keys[].required | Block deployment if key fails | true |

Supported Providers

| Provider | ID | Env var validated | |---|---|---| | OpenAI | openai | OPENAI_API_KEY | | Anthropic | anthropic | ANTHROPIC_API_KEY | | Google Gemini | gemini | GEMINI_API_KEY | | Stripe | stripe | STRIPE_SECRET_KEY | | Twilio | twilio | TWILIO_AUTH_TOKEN + TWILIO_ACCOUNT_SID | | Groq | groq | GROQ_API_KEY | | Mistral | mistral | MISTRAL_API_KEY | | OpenRouter | openrouter | OPENROUTER_API_KEY | | Together AI | togetherai | TOGETHER_API_KEY | | Cerebras | cerebras | CEREBRAS_API_KEY | | NVIDIA NIM | nvidia | NVIDIA_API_KEY | | Sarvam AI | sarvam | SARVAM_API_KEY | | PostHog | posthog | POSTHOG_PERSONAL_API_KEY | | Resend | resend | RESEND_API_KEY | | Loops | loops | LOOPS_API_KEY | | Clerk | clerk | CLERK_SECRET_KEY | | Fingerprint | fingerprint | FINGERPRINT_SECRET_KEY |

More providers coming. Open an issue to request one.

CI/CD Integration

GitHub Actions

- name: Validate API keys
  run: envguard validate
  env:
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
    STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}

Vercel

Set as Build Command:

envguard validate && next build

Render / Railway

Build Command:

envguard validate && npm run build

Fly.io

[deploy]
  release_command = envguard validate

Programmatic API

import { validateEnv } from '@ankitpandey2708/envguard';

// Uses envguard.json auto-detected from cwd
const result = await validateEnv();

// Pass config directly
const result = await validateEnv({
  keys: [
    { envVar: 'OPENAI_API_KEY', provider: 'openai' },
    { envVar: 'STRIPE_SECRET_KEY', provider: 'stripe' }
  ]
});

// Stop as soon as the first required key fails
const result = await validateEnv(config, { failFast: true });

if (!result.ok) {
  console.error('Key validation failed:', result.failed);
  process.exit(1);
}

Troubleshooting

| Problem | Fix | |---|---| | Key shows INVALID | Key was revoked or regenerated, or has wrong permissions | | Key shows UNKNOWN | Network issue or provider is down — try again | | Config not found | Ensure envguard.json exists, or use --config for a custom path |

Security

  • API keys are never logged or sent anywhere except the respective provider
  • All validation goes directly to providers — no intermediary service

License

MIT