Skip to content

[@vercel/blob] Read OIDC token via @vercel/oidc instead of inlined copy#1072

Merged
falcoagustin merged 3 commits into
mainfrom
falcoagustin/blob-use-oidc-package
Jun 15, 2026
Merged

[@vercel/blob] Read OIDC token via @vercel/oidc instead of inlined copy#1072
falcoagustin merged 3 commits into
mainfrom
falcoagustin/blob-use-oidc-package

Conversation

@falcoagustin

@falcoagustin falcoagustin commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

@vercel/blob shipped its own inlined copy of the Vercel OIDC token reader (the Symbol.for('@vercel/request-context') lookup + env fallback) rather than depending on @vercel/oidc. With no @vercel/oidc entry in its dependencies, blob's OIDC support was invisible from the package surface — to learn blob even uses OIDC, you had to read the bundled/minified dist source. (This came out of a thread where an agent burned ~20 min reverse-engineering blob auth from the dependency's code.)

Solution

Depend on @vercel/oidc and read the token via its getVercelOidcTokenSync — the same entry point every other consumer (apps/*, the AWS credential providers, @vercel/functions/oidc) uses. The OIDC dependency is now explicit and discoverable.

Blob's wrapper converts the library's "missing token" throw to undefined (so callers fall through to BLOB_READ_WRITE_TOKEN) and treats a blank token as absent.

Behavior change (one edge case): a blank x-vercel-oidc-token request-context header now resolves to no token rather than falling back to VERCEL_OIDC_TOKEN, because the library selects the header whenever its key is present. Everything else is unchanged.

Notes

  • @vercel/oidc transitively pulls in jose, whose browser build is ESM-only and broke the jsdom/edge jest environments (Unexpected token 'export'). blob is the first browser/edge-targeting consumer of @vercel/oidc, so this surfaces only here. Fixed by pinning jose to its CJS build in jest config (blob doesn't use jose directly).

Validation

  • node / edge / browser jest suites all pass (161 / 1 / 19).

🤖 Generated with Claude Code

Blob shipped its own inlined copy of the Vercel request-context reader, so
its OIDC support wasn't discoverable from the package's dependencies — an
agent had to read the bundled source to learn it used OIDC at all.

Depend on @vercel/oidc and use its `getContext` primitive. Behavior is
unchanged: Blob keeps its own resolution policy (trim tokens, ignore a blank
`x-vercel-oidc-token` header in favor of `VERCEL_OIDC_TOKEN`), since
@vercel/oidc's own token readers neither trim nor fall back on blank headers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vercel-storage-next-integration-test-suite Ready Ready Preview Jun 15, 2026 4:05pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a6e6df0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/blob Patch
vercel-storage-integration-test-suite Patch

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

@socket-security

socket-security Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​vercel/​oidc@​3.6.11001008598100

View full report

Depending on @vercel/oidc transitively pulls in jose (via verifyVercelOidcToken,
which Blob never calls). jose's browser/edge entry is ESM-only, so the jsdom and
edge-runtime jest environments resolved it and failed to parse it ("Unexpected
token 'export'") since jest doesn't transform node_modules. The node env was
unaffected because jose resolves to CJS there.

Move the jest config to jest.config.cjs and map `jose` to its CJS build in all
test environments. Blob doesn't use jose directly, so this only affects test
module resolution. Node/edge/browser suites all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch the OIDC reader from @vercel/oidc's low-level `getContext` to its
`getVercelOidcTokenSync`, matching how every other consumer uses the package.
The wrapper converts the lib's "missing token" throw to undefined (so callers
fall through to BLOB_READ_WRITE_TOKEN) and treats a blank token as absent.

Behavior change (edge case): a blank `x-vercel-oidc-token` header now resolves
to no token instead of falling back to VERCEL_OIDC_TOKEN, since the library
selects the header whenever its key is present. Test updated accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@falcoagustin falcoagustin marked this pull request as ready for review June 15, 2026 16:50
@falcoagustin falcoagustin merged commit b7027de into main Jun 15, 2026
10 checks passed
@falcoagustin falcoagustin deleted the falcoagustin/blob-use-oidc-package branch June 15, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants