(client: any)
| 13 | } |
| 14 | |
| 15 | export function configureClientAuth(client: any): any { |
| 16 | const authHeader = getAuthorizationHeader() |
| 17 | |
| 18 | if (!authHeader) { |
| 19 | return client |
| 20 | } |
| 21 | |
| 22 | // The SDK client has an internal client with request interceptors |
| 23 | // Access the underlying client to add the interceptor |
| 24 | const innerClient = client._client || client.client |
| 25 | |
| 26 | if (innerClient?.interceptors?.request) { |
| 27 | innerClient.interceptors.request.use((request: Request) => { |
| 28 | // Only add auth header if not already present |
| 29 | if (!request.headers.has("Authorization")) { |
| 30 | request.headers.set("Authorization", authHeader) |
| 31 | } |
| 32 | return request |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | return client |
| 37 | } |
no test coverage detected