feat: make initTokenRefreshLoop expiration-aware - #68
Draft
nicomiguelino wants to merge 2 commits into
Draft
Conversation
- Let onRefresh optionally resolve an { expiresAt } hint so the loop
can schedule the next run from the token's remaining lifetime
instead of a fixed interval
- Add an options object (maxIntervalSec, minDelaySec, lifetimeFraction)
for tuning the new scheduling behavior
- Fall back to the original fixed 30-minute interval and back-off
behavior when no hint is returned, keeping existing zero-arg
callers (Google Calendar, Outlook, Airtable) unchanged
- Add tests covering the fixed-interval path, expiration-aware
scheduling, hint fallback, and delay clamping
- Add an OAuth & Token Refresh section to README.md covering getCredentials and the new initTokenRefreshLoop options/expiresAt hint, with a fixed-interval and an expiration-aware example - Bump package version to 1.4.0 (minor, additive/backward-compatible change), aligned with a sibling PR bumping to the same version
nicomiguelino
added a commit
that referenced
this pull request
Jul 30, 2026
- Bump package.json/package-lock.json version from 1.3.0 to 1.4.0 - Shared with sibling PR #68 since it is unclear which of the two additive, backward-compatible changes will merge first
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.
Summary
initTokenRefreshLoop'sonRefreshcallback can now optionally resolve an{ expiresAt }hint, letting the loop schedule the next refresh as a clamped fraction of the token's remaining lifetime instead of a fixed interval.maxIntervalSec,minDelaySec,lifetimeFraction) tunes that behavior.() => Promise<void>(as used unchanged bygoogle-calendar-app,outlook-calendar-app, andairtable-app) still type-checks and behaves byte-for-byte the same — fixed 30-minute interval with the existing exponential back-off — since returning nothing falls back to the old fixed-interval path.1.4.0(aligned with sibling PR feat: return expiration from getCredentials #67, since we don't know which merges first).