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

@tokengate/env

v0.2.1

Published

Type-safe, encrypted environment variables from Tokengate cloud

Readme

@tokengate/env

Type-safe, encrypted environment variables from Tokengate cloud.

Stop leaking secrets. Stop sharing .env files over Slack. Define your schema once, get type-safe access everywhere, encrypted end-to-end.

Install

npm install @tokengate/env
# or
bun add @tokengate/env

Quick Start

import { createEnv } from '@tokengate/env'

const env = await createEnv({
  schema: {
    DATABASE_URL:    { type: 'string', required: true, sensitive: true },
    API_KEY:         { type: 'string', required: true, sensitive: true },
    PORT:            { type: 'port', default: 3000 },
    DEBUG:           { type: 'boolean', default: false },
    ALLOWED_ORIGINS: { type: 'string[]', separator: ',' },
    LOG_LEVEL:       { type: 'enum', values: ['debug', 'info', 'warn', 'error'], default: 'info' },
  }
})

env.DATABASE_URL  // string (guaranteed present)
env.PORT          // number (parsed from string)
env.DEBUG         // boolean (parsed from "true"/"false"/"1"/"0")
env.LOG_LEVEL     // "debug" | "info" | "warn" | "error"

Sync Version

For cases where async isn't available (e.g. config files):

import { createEnvSync } from '@tokengate/env'

const env = createEnvSync({
  schema: {
    PORT: { type: 'port', default: 3000 },
    NODE_ENV: { type: 'enum', values: ['development', 'production', 'test'], default: 'development' },
  }
})

Schema Types

| Type | Parses to | Example value | |------|-----------|---------------| | string | string | "hello" | | number | number | "42"42 | | boolean | boolean | "true"true, "1"true | | string[] | string[] | "a,b,c"["a","b","c"] | | number[] | number[] | "1,2,3"[1,2,3] | | url | string | Validated URL | | email | string | Validated email | | port | number | 0–65535 | | enum | string | One of values |

Schema Options

{
  type: 'string',       // Required: the type to parse as
  required: true,       // Default: true (false if default is set)
  default: 'fallback',  // Default value when not present
  sensitive: true,      // Mask in logs/debug output
  description: '...',   // Shown in generated docs
  values: ['a', 'b'],   // For enum type: allowed values
  separator: ',',       // For array types: split character
  validate: (v) => ..., // Custom validation function
}

Config File

Create tokengate.config.ts in your project root:

import { defineConfig } from '@tokengate/env'

export default defineConfig({
  project: 'web',
  environment: 'production',
  sources: ['cloud', 'file', 'process'], // Priority order
  cache: true,                            // Cache decrypted values locally
  cacheTtl: 300_000,                      // 5 minutes
  onError: 'throw',                       // 'throw' | 'warn' | 'silent'
  schema: {
    // ...
  }
})

Sources

Variables are loaded from these sources in priority order:

  1. cloud — Tokengate API (encrypted, decrypted locally with TOKENGATE_PASSWORD)
  2. file — Local .env file
  3. processprocess.env

The first source that returns values wins. process.env always overlays on top.

Generate Types

tokengate generate-types

Outputs:

  • env.d.ts — TypeScript declarations
  • .env.example — Template with types and defaults

Scan for Leaks

tokengate scan

Scans your codebase for hardcoded secret values found in your .env files.

Framework Integrations

License

MIT