Skip to content

Commit c614456

Browse files
authored
Pass teamId to the run-key endpoint (vercel#1183)
1 parent f0823dc commit c614456

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

.changeset/pass-teamid-run-key.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@workflow/world-vercel": patch
3+
---
4+
5+
Pass `teamId` to the run-key API endpoint for team-scoped encryption key retrieval

packages/world-vercel/src/encryption.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export async function fetchRunKey(
9494
options?: {
9595
/** Auth token (from config). Falls back to OIDC or VERCEL_TOKEN. */
9696
token?: string;
97+
/** Team ID for team-scoped API requests. */
98+
teamId?: string;
9799
}
98100
): Promise<Uint8Array | undefined> {
99101
// Authenticate via provided token (CLI/config), OIDC token (runtime),
@@ -107,6 +109,9 @@ export async function fetchRunKey(
107109
}
108110

109111
const params = new URLSearchParams({ projectId, runId });
112+
if (options?.teamId) {
113+
params.set('teamId', options.teamId);
114+
}
110115
const response = await fetch(
111116
`https://api.vercel.com/v1/workflow/run-key/${deploymentId}?${params}`,
112117
{
@@ -143,11 +148,13 @@ export async function fetchRunKey(
143148
* - Fetching it from the Vercel API when the run belongs to a different deployment
144149
*
145150
* @param projectId - Vercel project ID for HKDF context isolation
151+
* @param teamId - Optional team ID for team-scoped API requests
146152
* @param token - Optional auth token from config
147153
* @returns The `getEncryptionKeyForRun` function, or `undefined` if no projectId
148154
*/
149155
export function createGetEncryptionKeyForRun(
150156
projectId: string | undefined,
157+
teamId?: string,
151158
token?: string
152159
): World['getEncryptionKeyForRun'] {
153160
if (!projectId) return undefined;
@@ -188,6 +195,6 @@ export function createGetEncryptionKeyForRun(
188195
// raw deployment key never leaves the API boundary.
189196
// Covers cross-deployment resumeHook() (OIDC auth) and o11y
190197
// tooling reading data from other deployments (VERCEL_TOKEN).
191-
return fetchRunKey(deploymentId, projectId, runId, { token });
198+
return fetchRunKey(deploymentId, projectId, runId, { token, teamId });
192199
};
193200
}

packages/world-vercel/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function createVercelWorld(config?: APIConfig): World {
2727
...createStreamer(config),
2828
getEncryptionKeyForRun: createGetEncryptionKeyForRun(
2929
projectId,
30+
config?.projectConfig?.teamId,
3031
config?.token
3132
),
3233
};

0 commit comments

Comments
 (0)