MCPcopy Create free account
hub / github.com/vercel/vercel / parseOidcToken

Function parseOidcToken

packages/container/src/oidc.ts:11–25  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

9}
10
11export function parseOidcToken(token: string): OidcTokenPayload {
12 const parts = token.split('.');
13 if (parts.length !== 3) {
14 throw new Error(
15 'VERCEL_OIDC_TOKEN is not a valid JWT (expected 3 dot-separated segments).'
16 );
17 }
18
19 try {
20 const json = Buffer.from(parts[1], 'base64url').toString('utf8');
21 return JSON.parse(json) as OidcTokenPayload;
22 } catch {
23 throw new Error('VERCEL_OIDC_TOKEN has an unreadable JWT payload.');
24 }
25}
26
27function resolveProjectContext(token: string): {
28 projectId?: string;

Callers 1

resolveProjectContextFunction · 0.85

Calls 3

splitMethod · 0.80
toStringMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected