Configuration
Learn how to configure the SecretStash Node module for your project.
The SecretStash Node module resolves configuration using the following priority order:
- Constructor arguments (programmatic usage only — highest priority)
- System environment variables
.envfile in the current working directory- Default values
This means you can configure the module entirely through your project's .env file, by exporting environment variables in your shell, or by passing values directly when constructing the client programmatically.
Environment Variables
The following environment variables are supported:
| Variable | Description | Default |
|---|---|---|
SECRET_STASH_API_TOKEN | Your personal API token for authenticating with the SecretStash API. | null |
SECRET_STASH_APPLICATION_ID | Your SecretStash Application ID. | null |
SECRET_STASH_API_URL | The base URL for the SecretStash API. | https://secretstash.cloud |
SECRET_STASH_KEY_DIR | Override the default ~/.secret-stash/ key directory. | ~/.secret-stash/ |
Both SECRET_STASH_API_TOKEN and SECRET_STASH_APPLICATION_ID are required. The module will throw an error if either is missing when attempting to make API calls.
API Token
Your personal API token for authenticating with the SecretStash API. Generate a token in the SecretStash web application under Profile → Tokens.
It is recommended to store your API token in your .env file rather than hardcoding it in your application code.
Application ID
The unique application ID supplied by the SecretStash service. This identifies which application's variables the CLI or API should interact with.
When using the CLI, you can also override this per-command with the -a or --application flag:
API URL
The base URL for your SecretStash API instance:
This is only needed for testing or self-hosted instances. The default value (https://secretstash.cloud) is correct for most users.
Key Directory Override
By default, the SecretStash Node module stores device keys and metadata in the ~/.secret-stash/ directory. You can override this path by setting the SECRET_STASH_KEY_DIR environment variable:
When SECRET_STASH_KEY_DIR is set, all SecretStash commands and programmatic API calls will read device keys from the specified directory instead of ~/.secret-stash/.
This is primarily useful for temporary device keys in CI/CD pipelines. When you run secret-stash key init --temporary, the module generates keys into an isolated /tmp directory and prints the SECRET_STASH_KEY_DIR export line. Setting this variable in subsequent pipeline steps allows those commands to locate the temporary keys.
The directory specified by SECRET_STASH_KEY_DIR must contain valid device_private_key.pem and device.json files. If the directory does not exist or the key files are missing, commands will fail.
Ignored Variables
The following variables are always ignored when pushing to or pulling from SecretStash:
- Any variable starting with the
SECRET_STASH_prefix APP_KEYAPP_ENV
These defaults are built into the module and cannot be customized via a configuration file.
Programmatic Configuration
When using the module as a project dependency, you can pass configuration values directly to the SecretStashClient constructor:
If constructor arguments are omitted, the client falls back to the standard resolution order (environment variables → .env file → defaults). See Programmatic Usage for the full API reference.
Node module source code: https://github.com/dniccum/secret-stash-node