Repository navigation
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| teamId: credentials.teamId, | ||
| token: credentials.token, | ||
| fetch: params?.fetch, | ||
| getAuthHeaders: params?.getAuthHeaders, |
Contributor
This branch was successfully deployed
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.
Adds an optional
getAuthHeaders(method, url)to@vercel/sandboxand tocreateAppinsandbox, so a caller can authenticate each API request with its own headers instead ofAuthorization: Bearer <token>. The Vercel CLI needs this to runvercel sandboxwith a DPoP-bound login (RFC 9449): a DPoP token must be sent with a new proof signed for each request's method and URL, which a token passed throughVERCEL_AUTH_TOKENcan't do. Without the option, nothing changes.@vercel/sandboxgetAuthHeadersis part ofWithFetchOptions, so every static entry point that takesfetchtakes it too (Sandbox.list/create/fork/get/getOrCreate,Snapshot.list/tree/get,Drive.list/get/getOrCreate), and instances reuse that client.BaseClientwrapsfetchwith it belowwithRetry, so every attempt, including 429/5xx retries, gets new headers. When it's set,tokenisn't sent and isn't treated as an OIDC token to refresh.onResponse(url, headers)property gets every response's headers, so a caller can keep a server'sDPoP-Nonce. A 401 withuse_dpop_nonceand aDPoP-Nonceis sent once more with new headers, unless its body is a stream.inferScopeand itsfetchApiaccept it too. TheAuthHeadersProvidertype is exported.sandboxcreateApp({ appName, withoutAuth, getAuthHeaders })uses the provider when no--tokenorVERCEL_AUTH_TOKENis given: the token option resolves to""without looking up OIDC or stored credentials or starting a login, and scope inference and every SDK call use the provider.Validation
auth-headers.test.ts: headers set per request with the method and full URL,onResponsecalled, one resend on a nonce challenge (at most once, never for a stream body),APIClientsending the provider's headers instead ofBearerwith new headers on a 5xx retry, a JWT-shaped token not refreshed,Bearerunchanged without a provider, andfetchApiusing the provider.""with a provider and doesn't look up a token,VERCEL_AUTH_TOKENstill wins, andsandboxClientsends the provider's headers (with the CLI user agent) only when there's no token. These fail without the change.@vercel/sandbox: typecheck passes and unit tests pass, exceptpackage-exports.test.ts, which also fails onmainwithout a build.sandbox: typecheck and all 228 tests pass.@vercel/sandbox-mocktests pass.