The official TypeScript/Node.js client for the XtraSecurity API. Built with native caching, TypeScript definitions, and Zero-Trust injection.
The SDK provides a primary wrapper class, XtraClient. It accepts an XtraClientOptions object during instantiation.
| Option | Type | Default | Description |
|---|---|---|---|
| token | string | process.env.XTRA_TOKEN | The API Token used for authentication. |
| projectId | string | process.env.XTRA_PROJECT_ID | The default project ID for all secret operations. |
| apiUrl | string | https://www.xtrasecurity.in/api | Override the base URL for self-hosted Enterprise instances. |
| cache | boolean | true | Enables in-memory caching to prevent rate-limiting on high-traffic apps. |
| cacheTtl | number | 30000 | Time-to-live for cached secrets in milliseconds (default: 30 seconds). |
Fetches all secrets for a specific environment and branch, returning a standard key-value dictionary. This method automatically utilizes the in-memory cache if enabled.
| Parameter | Type | Description |
|---|---|---|
| env | 'development' | 'staging' | 'production' | Required. The target environment. |
| projectId? | string | Optional override for the default projectId. |
| branch? | string | Optional. Target a specific environment branch (defaults to 'main'). |
| noCache? | boolean | Optional. If true, forces a network request bypassing the in-memory cache. |
A convenience method that fetches secrets and immediately populates process.env. This is the recommended approach for serverless functions and Express backends.
index.ts).Manually flushes the in-memory secret cache. Useful when responding to webhook events notifying you of secret changes.
For power users building custom internal tools, XtraClient exposes the raw auto-generated service classes. You have full programmatic access to Projects, Teams, Audits, Branches, and Notifications.
All internal SDK errors are thrown as instances of the XtraError class. Network or HTTP errors from the underlying API will throw standard Axios errors containing status codes and response data.