(token: string)
| 9 | } |
| 10 | |
| 11 | export 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 | |
| 27 | function resolveProjectContext(token: string): { |
| 28 | projectId?: string; |
no test coverage detected