मुख्य सामग्री पर जाएं

Secrets

Kazzle के पास API keys, database credentials, tokens, और अन्य sensitive values को store करने के लिए एक built-in encrypted vault है जिसकी आपके app को जरूरत है। Secrets को AES-256-GCM के साथ rest में encrypt किया जाता है जो KMS-wrapped data encryption keys का उपयोग करता है — plaintext values कभी database को touch नहीं करते।

Concepts

Collections related secrets को एक साथ group करते हैं (जैसे stripe-keys, database-credentials)। हर collection के पास एक slug होता है (lowercase, hyphenated) जिसे आप config files और CLI commands में reference करते हैं। Environments एक collection के भीतर optional scopes हैं (जैसे production, staging)। Secrets को एक specific environment के लिए scoped किया जा सकता है या collection level पर defaults के रूप में छोड़ा जा सकता है। Resolution order: जब किसी दिए गए collection + environment के लिए secrets को resolve किया जाता है, तो environment-specific secrets collection-level secrets को same name के साथ override करते हैं। यह आपको अधिकांश secrets को environments में share करने देता है जबकि specific values को per-environment override करता है।

Managing secrets

App में

Settings > Vault खोलें ताकि आप UI के माध्यम से collections, environments, और secrets बना सकें।

AI के साथ

AI आपके लिए collections बना सकता है, environments बना सकता है, secrets store कर सकता है, उन्हें scopes के बीच move कर सकता है, और उन्हें delete कर सकता है। AI secret names और metadata देख सकता है लेकिन encrypted values नहीं।

CLI के साथ

# Secrets को env vars के रूप में inject करके एक command चलाएं
kazzle run --collection=stripe-keys --env=production -- bun run server.ts

# Secrets को KEY=value lines के रूप में export करें
kazzle secrets.export --collection=stripe-keys --env=production

अपने app से secrets को reference करना

kazzle.config.ts में एक component के env को एक secret collection और environment पर point करें। उस scope में हर secret को एक process env var के रूप में inject किया जाता है जिसका नाम secret name से match करता है:
import { defineConfig } from './kazzle.types';

export default defineConfig({
  components: [
    {
      name: 'API Server',
      type: 'process',
      path: './server',
      env: {
        collection: 'stripe-keys',
        environment: 'production'
      }
    }
  ]
});
env.collection और env.environment slugs हैं, display names नहीं। Collection के secrets के एक subset को inject करने के लिए env.include का उपयोग करें:
env: {
  collection: 'stripe-keys',
  environment: 'production',
  include: ['STRIPE_SECRET_KEY']
}

Secrets कैसे env vars बनते हैं

जब एक component के लिए secrets को resolve किया जाता है:
  1. Collection को आपके space के भीतर slug द्वारा खोजा जाता है
  2. Specified environment के लिए scoped secrets को load किया जाता है
  3. Collection-level secrets (कोई environment नहीं) को defaults के रूप में शामिल किया जाता है
  4. Environment-specific secrets collection-level ones को same name के साथ override करते हैं
  5. Values के अंदर secret references को resolve किया जाता है
  6. Secret names को env var format में convert किया जाता है: uppercased, non-alphanumeric characters underscores बन जाते हैं
Stripe Secret Key नाम वाला एक secret STRIPE_SECRET_KEY बन जाता है। हर secret के पास एक body mode होता है जो यह determine करता है कि इसे कैसे inject किया जाता है:
  • string secrets (API keys, tokens, URIs) को plain scalar strings के रूप में inject किया जाता है
  • json secrets (structured config) को JSON strings के रूप में inject किया जाता है
  • fields secrets (login credentials, typed field bags) को JSON strings के रूप में inject किया जाता है

जब secrets को inject किया जाता है

ContextInjected?Details
Deploy (process component)YesProduction में runtime environment variables के रूप में जोड़े जाते हैं
Deploy (UI component)Partialकेवल VITE_* prefixed secrets को build time पर pass किया जाता है
CLI (kazzle run)YesCommand के environment में inject किए जाते हैं
CLI (secrets.export)YesKEY=value lines के रूप में export किए जाते हैं
Dev previewNot yetPreview starter अभी component env को resolve नहीं करता — अभी के लिए kazzle run का उपयोग करें

Template references

Secret values अन्य secret fields को reference कर सकते हैं जो Kazzle कहीं और उपयोग करता है:
postgresql://${secret.123e4567-e89b-12d3-a456-426614174000.username}:${secret.123e4567-e89b-12d3-a456-426614174000.password}@db.example.com:5432/mydb
Supported formats:
  • ${secret.<uuid>.<field>} — specific field या JSON path। App env/config के लिए इस format का उपयोग करें।
  • ${secret.<uuid>} — पूरा secret body। केवल तब उपयोग करें जब कोई tool explicitly पूरे raw secret के लिए पूछे; app env/config में इसका उपयोग न करें।
References को secrets load होने के बाद resolve किया जाता है। Circular या broken references silently fallback के बजाय fail होते हैं।