Add automatic token and lease renewal with event-based lifecycle management#292
Merged
aviadhahami merged 3 commits intomasterfrom Mar 21, 2026
Merged
Conversation
…EventEmitter support Co-authored-by: aviadhahami <7353632+aviadhahami@users.noreply.github.com> Agent-Logs-Url: https://github.com/nodevault/node-vault/sessions/d86303c3-13a8-4f83-9355-64b288991fa5
…ents Co-authored-by: aviadhahami <7353632+aviadhahami@users.noreply.github.com> Agent-Logs-Url: https://github.com/nodevault/node-vault/sessions/d86303c3-13a8-4f83-9355-64b288991fa5
Copilot
AI
changed the title
[WIP] Add support for dynamic credentials in Node.js application
Add automatic token and lease renewal with event-based lifecycle management
Mar 21, 2026
aviadhahami
approved these changes
Mar 21, 2026
aviadhahami
approved these changes
Mar 21, 2026
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.
The library exposes
tokenRenewSelf()andrenew()but provides no automatic scheduling or notification mechanism for dynamic credentials. Users managing short-lived tokens or database credential leases (e.g., TTL: 1h, MAX_TTL: 24h) must implement their own renewal loops and handle credential rotation manually.Changes
EventEmitter— enableson/once/offfor lifecycle eventsstartTokenRenewal(opts)/stopTokenRenewal()scheduletokenRenewSelfat a configurable fraction of TTL (default 80%). TTL can be passed directly or auto-detected viatokenLookupSelf().startLeaseRenewal(leaseId, duration, opts)/stopLeaseRenewal(leaseId)/stopAllRenewals()for managing dynamic secret leases independentlytoken:renewed,token:expired,token:error:renew,lease:renewed,lease:expired,lease:error:renewTokenRenewalOptions,LeaseRenewalOptions, EventEmitter methods, and new API signaturesunref()'d to avoid keeping the process aliveUsage
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.