Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-owls-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/world-vercel": patch
---

Reorder token resolution in `fetchRunKey` and `resolveLatestDeploymentId` to prefer `options.token` / `VERCEL_TOKEN` before calling OIDC, skipping the OIDC network call when a token is already available
12 changes: 8 additions & 4 deletions packages/world-vercel/src/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ export async function fetchRunKey(
teamId?: string;
}
): Promise<Uint8Array | undefined> {
// Authenticate via provided token (CLI/config), OIDC token (runtime),
// or VERCEL_TOKEN env var (external tooling)
const oidcToken = await getVercelOidcToken().catch(() => null);
const token = options?.token ?? oidcToken ?? process.env.VERCEL_TOKEN;
// Authenticate via provided token (CLI/config), VERCEL_TOKEN env var
// (external tooling), or OIDC token (runtime) — in that order.
// OIDC is last to avoid an unnecessary network call when a token is
// already available (e.g. CLI or CI contexts).
const token =
options?.token ??
process.env.VERCEL_TOKEN ??
(await getVercelOidcToken().catch(() => null));
if (!token) {
Comment thread
TooTallNate marked this conversation as resolved.
throw new Error(
'Cannot fetch run key: no OIDC token or VERCEL_TOKEN available'
Expand Down
12 changes: 8 additions & 4 deletions packages/world-vercel/src/resolve-latest-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ export function createResolveLatestDeploymentId(
);
}

// Authenticate via provided token (CLI/config), OIDC token (runtime),
// or VERCEL_TOKEN env var (external tooling)
const oidcToken = await getVercelOidcToken().catch(() => null);
const token = config?.token ?? oidcToken ?? process.env.VERCEL_TOKEN;
// Authenticate via provided token (CLI/config), VERCEL_TOKEN env var
// (external tooling), or OIDC token (runtime) — in that order.
// OIDC is last to avoid an unnecessary network call when a token is
// already available (e.g. CLI or CI contexts).
const token =
config?.token ??
process.env.VERCEL_TOKEN ??
(await getVercelOidcToken().catch(() => null));
Comment thread
TooTallNate marked this conversation as resolved.
if (!token) {
throw new Error(
'Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available'
Expand Down
Loading