Secrets API
Secure credential management with Google Cloud Secret Manager and Cloud KMS integration.
What It Does
The Secrets API provides a high-level interface for securely managing secrets and cryptographic signing keys in Google Cloud Platform. It wraps GCP Secret Manager for credential storage and Cloud KMS for asymmetric signing operations, with intelligent caching, automatic retries, and type-safe access patterns.
Key Capabilities
| Capability | Description |
|---|---|
| Secret Management | Store, retrieve, update, and delete secrets in GCP Secret Manager |
| Process Caching | Automatic in-memory caching for performance optimization |
| JSON Secret Support | Parse and type JSON secrets into TypeScript objects |
| Binary Data Support | Store and retrieve non-text data via buffering |
| Asymmetric Signing | RSA-2048 digital signatures with SHA-256 hashing |
| Key Management | Automatic key ring creation and key lifecycle management |
| Data Integrity | CRC32C checksums for signature validation |
| Retry Logic | Exponential backoff for resilient secret access |
| Auto Project Discovery | Multiple strategies to find GCP project ID |
| Type Safety | Full TypeScript support with generic types |
Configuration
Project ID Discovery
- Automatic detection from multiple sources
- Fallback chain for reliability
- Manual override via constructor
Cache Configuration
- Default: Enabled (process.env caching)
- Disable: skipCaching: true option
- Per-secret cache control
Retry Configuration
- Max attempts: 5
- Exponential backoff
- Configurable via constants
Exports
Services
SecretsService- Secret managementSigningKeyManager- Key management and signing
Models
ISigningKey- Public key interfaceIEncryptionKey- Key reference interfaceISigningKeyManagerOptions- Manager configuration
Types
AccessSecretOptions- Secret access options
Constants
- Error types (secrets/corrupted-request)
Common Use Cases
- API credentials: Store API keys, tokens, passwords securely
- Database credentials: Manage connection strings and passwords
- Certificate storage: Store TLS certificates and private keys
- JWT signing: Create and manage signing keys for JWTs
- Configuration secrets: Store environment-specific configs
- Encryption keys: Manage encryption key material
- Third-party integrations: Store OAuth tokens and secrets
- Audit trail signing: Digital signatures for non-repudiation
Roadmap
Multi-Cloud Support
This API currently supports Google Cloud Platform. Future versions will add support for additional cloud providers and container-based deployment options, enabling greater flexibility in infrastructure choices.
What Customers Don’t Have to Build
- GCP Secret Manager integration
- Process-level secret caching
- Project ID discovery logic
- JSON secret parsing
- Binary data handling
- Exponential backoff retry
- Secret lifecycle management (CRUD)
- RSA asymmetric signing
- Cloud KMS integration
- CRC32C checksum validation
- Key ring management
- Automatic key creation
- Public key retrieval
- SHA-256 hashing for signatures
- Error classification and wrapping
- Type-safe secret access
- Version management
- Graceful error handling
Last updated on