(data: Record<string, any>)
| 76 | * @throws Error if the data is not a valid object (null, undefined, array, or primitive type) |
| 77 | */ |
| 78 | export function extractOAuth2TokenFields(data: Record<string, any>): Record<string, any> { |
| 79 | if (!data || typeof data !== 'object' || Array.isArray(data)) { |
| 80 | throw new Error('Invalid OAuth2 token response: expected an object') |
| 81 | } |
| 82 | |
| 83 | const result: Record<string, any> = {} |
| 84 | for (const key of ALLOWED_OAUTH2_TOKEN_FIELDS) { |
| 85 | if (data[key] !== undefined) { |
| 86 | result[key] = data[key] |
| 87 | } |
| 88 | } |
| 89 | return result |
| 90 | } |
no outgoing calls
no test coverage detected