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/pass-teamid-run-key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/world-vercel": patch
---

Pass `teamId` to the run-key API endpoint for team-scoped encryption key retrieval
9 changes: 8 additions & 1 deletion packages/world-vercel/src/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export async function fetchRunKey(
options?: {
/** Auth token (from config). Falls back to OIDC or VERCEL_TOKEN. */
token?: string;
/** Team ID for team-scoped API requests. */
teamId?: string;
}
): Promise<Uint8Array | undefined> {
// Authenticate via provided token (CLI/config), OIDC token (runtime),
Expand All @@ -107,6 +109,9 @@ export async function fetchRunKey(
}

const params = new URLSearchParams({ projectId, runId });
if (options?.teamId) {
params.set('teamId', options.teamId);
}
Comment on lines +112 to +114
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test case to verify that the teamId query parameter is correctly included in the API request when options.teamId is provided. This would ensure the teamId is properly appended to the URL as expected by the Vercel API.

Copilot uses AI. Check for mistakes.
const response = await fetch(
`https://api.vercel.com/v1/workflow/run-key/${deploymentId}?${params}`,
{
Expand Down Expand Up @@ -143,11 +148,13 @@ export async function fetchRunKey(
* - Fetching it from the Vercel API when the run belongs to a different deployment
*
* @param projectId - Vercel project ID for HKDF context isolation
* @param teamId - Optional team ID for team-scoped API requests
* @param token - Optional auth token from config
* @returns The `getEncryptionKeyForRun` function, or `undefined` if no projectId
*/
export function createGetEncryptionKeyForRun(
projectId: string | undefined,
teamId?: string,
token?: string
): World['getEncryptionKeyForRun'] {
if (!projectId) return undefined;
Expand Down Expand Up @@ -188,6 +195,6 @@ export function createGetEncryptionKeyForRun(
// raw deployment key never leaves the API boundary.
// Covers cross-deployment resumeHook() (OIDC auth) and o11y
// tooling reading data from other deployments (VERCEL_TOKEN).
return fetchRunKey(deploymentId, projectId, runId, { token });
return fetchRunKey(deploymentId, projectId, runId, { token, teamId });
};
}
1 change: 1 addition & 0 deletions packages/world-vercel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function createVercelWorld(config?: APIConfig): World {
...createStreamer(config),
getEncryptionKeyForRun: createGetEncryptionKeyForRun(
projectId,
config?.projectConfig?.teamId,
config?.token
),
};
Expand Down
Loading