[@vercel/blob] Use refreshing getVercelOidcToken from @vercel/oidc#1076
Merged
Conversation
Switch the blob OIDC reader from @vercel/oidc's non-refreshing getVercelOidcTokenSync to the async getVercelOidcToken, which refreshes an expired token in development. The wrapper, resolveBlobAuth, and its two call sites (requestApi, get) become async accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 3e70cab The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
agadzik
approved these changes
Jun 25, 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.
Problem
@vercel/blobreads the Vercel OIDC token via@vercel/oidc'sgetVercelOidcTokenSync(introduced in #1072). That sync variant only reads the token from the request-context header /VERCEL_OIDC_TOKENenv var — it never refreshes an expired token. In a development environment a long-lived session can end up holding a stale, expired OIDC token.Solution
Switch the blob OIDC reader to
@vercel/oidc's asyncgetVercelOidcToken, which refreshes an expired token in development before returning it. The thin wrapper invercel-oidc-token.tsbecomesasync, and that propagates toresolveBlobAuthand its two call sites (requestApi,get) — both alreadyasync.Behavior is unchanged in production with a valid, unexpired token: the refreshing variant decodes the token, finds it valid, and returns it immediately without any CLI access. If a refresh is required but fails (no CLI creds, no project config, network error), the wrapper swallows the throw and returns
undefined, so callers still fall back toBLOB_READ_WRITE_TOKEN— the same graceful degradation as before.Tests mock
@vercel/oidcto delegate the refreshing reader to the real sync reader: the refresh path uses dynamicimport(), which jest's CJS runner can't execute without--experimental-vm-modules, so the mock preserves the genuine header/env source-resolution while sidestepping that limitation.🤖 Generated with Claude Code