(auth: HttpAuth)
| 95 | } |
| 96 | |
| 97 | function authHeaders(auth: HttpAuth): HttpHeaderEntry[] { |
| 98 | if (auth.type === 'bearer' && auth.token) { |
| 99 | return [{ key: 'Authorization', value: `Bearer ${auth.token}` }] |
| 100 | } |
| 101 | |
| 102 | if (auth.type === 'basic' && auth.username !== undefined) { |
| 103 | return [ |
| 104 | { |
| 105 | key: 'Authorization', |
| 106 | value: `Basic ${encodeBasicCredentials( |
| 107 | auth.username, |
| 108 | auth.password ?? '', |
| 109 | )}`, |
| 110 | }, |
| 111 | ] |
| 112 | } |
| 113 | |
| 114 | return [] |
| 115 | } |
| 116 | |
| 117 | function hasHeader(headers: HttpHeaderEntry[], name: string): boolean { |
| 118 | return headers.some(header => header.key.toLowerCase() === name) |
no test coverage detected