| 49 | const liveServers: MockOauthServer[] = [] |
| 50 | |
| 51 | function getHeaderValue( |
| 52 | headers: unknown, |
| 53 | key: string, |
| 54 | ): string | undefined { |
| 55 | if (!headers || typeof headers !== 'object') { |
| 56 | return undefined |
| 57 | } |
| 58 | |
| 59 | const direct = (headers as Record<string, string | undefined>)[key] |
| 60 | if (typeof direct === 'string') { |
| 61 | return direct |
| 62 | } |
| 63 | |
| 64 | const getter = (headers as { get?: (name: string) => string | undefined }).get |
| 65 | if (typeof getter === 'function') { |
| 66 | return getter.call(headers, key) |
| 67 | } |
| 68 | |
| 69 | return undefined |
| 70 | } |
| 71 | |
| 72 | function restoreEnv(): void { |
| 73 | for (const key of envKeys) { |