Repository navigation
feat(refresh): use Lambda /refresh endpoint before gh fallback (v0.13.3) - #68
Conversation
License refresh no longer hard-depends on the GitHub CLI. The plugin now
POSTs the expired JWT to the Lambda's /refresh endpoint first; gh-cli
silent activation is the safety net for users whose sliding-refresh
window has elapsed (Lambda returns 410) or whose environment hasn't
deployed /refresh yet (404).
Behavior:
Before: every refresh required `gh auth token` + GitHub /user + /user/orgs
→ gh-less users effectively couldn't refresh
After: refresh hits Lambda /refresh directly (server checks signature +
sliding window + DB org status, no GitHub roundtrip)
→ gh-less users keep working as long as they're inside the 7-day
sliding window from their last full /activate
Files:
lib/license-activation.js
+ getRefreshUrl() — derives from getActivateUrl, preserves host config
+ refreshExpiredJwt(jwt, deviceId) — POSTs to /refresh, returns new JWT
or null. On null, the caller's silent-gh fallback runs.
· 410/404/network/parse errors all return null (caller falls back).
· On 200, writes the new JWT to credstore atomically.
logger.js
· tryRefreshLicense tries refreshExpiredJwt first, falls back to
trySilentGhActivate on null result.
· Existing signed_out / no-deviceId early returns preserved.
Deploy-order-safe: Lambda /refresh endpoint may not be reachable in every
environment yet. 404 from the client is silently absorbed into the gh
fallback path so there's no visible regression during rollout.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Disabled knowledge base sources:
WalkthroughThis PR adds JWT token refresh capability to the license activation system. It introduces a new ChangesLicense JWT Token Refresh with Fallback
Sequence DiagramsequenceDiagram
participant Logger as Logger.tryRefreshLicense
participant RefreshJWT as refreshExpiredJwt
participant RefreshEndpoint as /refresh endpoint
participant Credstore as Credstore
participant GhActivate as trySilentGhActivate
Logger->>RefreshJWT: refreshExpiredJwt(current_jwt, deviceId)
RefreshJWT->>RefreshEndpoint: POST with Bearer token & device_id
alt Success (200 OK, valid token)
RefreshEndpoint-->>RefreshJWT: new_jwt
RefreshJWT->>Credstore: write new_jwt
RefreshJWT-->>Logger: return new_jwt
else 410 Expiry or 404 Missing
RefreshEndpoint-->>RefreshJWT: error response
RefreshJWT-->>Logger: return null
Logger->>GhActivate: fallback to GitHub activation
else Other non-OK status
RefreshEndpoint-->>RefreshJWT: error response
RefreshJWT-->>Logger: return null
Logger->>GhActivate: fallback to GitHub activation
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.21.0)OpenGrep fatal error (exit code 2): �[32m✔�[39m �[1mOpengrep OSS�[0m �[1m Loading rules from local config...�[0m Comment |
Summary
License refresh no longer hard-depends on the GitHub CLI. The plugin POSTs the expired JWT to the Lambda's `/refresh` endpoint first; gh silent activation is the safety net for users whose 7-day sliding window has elapsed or whose environment hasn't deployed `/refresh` yet.
Before: every refresh required `gh auth token` + GitHub `/user` + `/user/orgs`. gh-less users effectively couldn't refresh.
After: refresh hits Lambda `/refresh` directly (server checks signature + sliding window + DB org status, no GitHub round-trip). gh-less users keep working as long as they're inside the sliding window.
Files
Deploy-order safety
Lambda `/refresh` may not be reachable in every environment yet. 404 from the client is silently absorbed into the gh fallback path so there's no observable regression during rollout.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
New Features