XyPriss features a military-grade Environment Security Shield designed to eliminate secret leakage and enforce robust application architecture.
Traditional Node.js applications rely heavily on process.env. While convenient, this approach has several flaws:
- Global Exposure: Any third-party library or dependency can read
process.env, potentially leaking your database credentials or API keys to malicious actors or telemetry services. - Accidental Logging: Developers often log
process.envduring debugging, unintentionally printing sensitive secrets to stdout or cloud logs. - Implicit Dependencies: Code becomes hard to test and maintain when it depends on global, mutable state.
XyPriss uses a native System Proxy to intercept all access to process.env.
XyPriss includes a built-in, ultra-fast .env loader. It automatically looks for and merges the following files (in order of priority):
.private/.env.env.local.env
Note: You no longer need require('dotenv').config() or any external environment loaders.
When code attempts to read from process.env, the shield performs a security check:
- Whitelisted core variables (e.g.,
NODE_ENV,PATH,PORT,TERM) are returned normally. - Project-prefixed variables (starting with
XYPRISS_,XY_,ENC_, orDOTENV_) are returned normally. - All other variables return
undefinedand trigger a security warning in the console.
To access your application variables, use the system-managed environment manager:
// ❌ Discouraged
const apiKey = process.env.MY_API_KEY;
// ✅ Recommended
const apiKey = __sys__.__env__.get("MY_API_KEY");The following variables are always accessible directly via process.env to ensure system and runtime stability:
| Variable | Description |
|---|---|
NODE_ENV |
Current runtime environment |
PORT |
Standard listening port |
PATH |
System execution paths |
USER |
Current system user |
HOME |
User home directory |
LANG |
System language/locale |
COLORTERM |
Terminal color support |
XYPRISS_* |
All official framework configurations |
ENC_* |
Encryption keys and seeds |
- Use Prefixes: For environment variables that MUST be accessed by legacy libraries, prefix them with
XYPRISS_. - Standardize Access: Use
__sys__.__env__.get()everywhere in your business logic. - Use .private/.env: This file is automatically loaded and is the ideal place for hardware-local secrets that should never be committed to version control.