[Feature] vault refresh callback and helpers#55
Merged
Conversation
Release/2026 02 03
## [2.12.2](v2.12.1...v2.12.2) (2026-02-03) ### Bug Fixes * **vault:** register config instance for automatic refresh updates ([fe94863](fe94863))
- Add SecretRefreshEvent type and onSecretRefreshed callback to IVaultConfigOptions - Refactor SecretRefreshManager to perform path-aware refresh: all properties sharing a Vault path are updated from a single read, preventing credential mismatch for database engine secrets (username/password) - Fire one callback event per path refresh with affected properties list - Wire callback through VaultIntegration and expose on ConfigService - Add buildVaultConfigFromEnv() helper that builds IVaultConfigOptions from VAULT_ADDR, VAULT_TOKEN, and VAULT_GCP_ROLE environment variables - Export new helpers and types from vault/index.ts - Add unit tests for buildVaultConfigFromEnv (12 tests) - Add integration tests for callback, path-level refresh, and dynamic secrets (7 tests) - Fix test-vault-dynamic.ts VaultPath prefixes for correct Vault reads - Update jest-stare 2.5.0 -> 2.5.3 to fix Node 22+ crash (util.isNullOrUndefined removed) Made-with: Cursor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## beta #55 +/- ##
===========================================
+ Coverage 34.08% 47.63% +13.55%
===========================================
Files 11 12 +1
Lines 1018 1079 +61
Branches 246 262 +16
===========================================
+ Hits 347 514 +167
+ Misses 610 565 -45
+ Partials 61 0 -61 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- SecretRefreshManager: 19 tests covering path-level atomic refresh, callback registration, error handling, and status - VaultIntegration callback wiring: 4 tests for constructor and runtime onSecretRefreshed delegation - ConfigService.onSecretRefreshed: 2 tests for delegation and no-op when vault not configured Raises secret-refresh-manager.ts from 0.81% to 95% coverage. Made-with: Cursor
|
This PR is included in version 2.13.0-beta.1 🎉 The release is available on: |
|
This PR is included in version 2.13.0 🎉 The release is available on: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
onSecretRefreshedcallback: NewSecretRefreshEventtype andSecretRefreshCallbackallowing consumers to react when Vault secrets are refreshed (e.g., reconnect a database pool). Can be registered viaIVaultConfigOptions.onSecretRefreshedat construction orconfigService.onSecretRefreshed()at runtime.SecretRefreshManagerso that all properties sharing the same Vault path (e.g.,DB_USERNAMEandDB_PASSWORDfromdatabase/creds/my-role) are updated from a single Vault read. This prevents credential mismatch where username comes from one lease and password from another. One callback event fires per path, listing all affected properties.buildVaultConfigFromEnv()helper: New utility that buildsIVaultConfigOptionsfrom standard environment variables (VAULT_ADDR,VAULT_TOKEN,VAULT_GCP_ROLE). Returnsundefinedwhen Vault is not configured, so configit falls back to env vars/config files. Reduces boilerplate across microservices.jest-stare2.5.0 → 2.5.3 to fixutil.isNullOrUndefinedcrash on Node 22+.@VaultPathprefixes intest-vault-dynamic.tsthat caused double-prefixed paths (secret/data/secret/data/...).