( rawAuth: unknown, source: string, warnings: HttpImportWarning[], )
| 93 | } |
| 94 | |
| 95 | function parseAuth( |
| 96 | rawAuth: unknown, |
| 97 | source: string, |
| 98 | warnings: HttpImportWarning[], |
| 99 | ): HttpAuth | null { |
| 100 | if (!isRecord(rawAuth)) { |
| 101 | return null |
| 102 | } |
| 103 | |
| 104 | const type = asString(rawAuth.type).toLowerCase() |
| 105 | if (!type || type === 'noauth') { |
| 106 | return { type: 'none' } |
| 107 | } |
| 108 | |
| 109 | if (type === 'bearer') { |
| 110 | const token = getKeyValueArrayValue(rawAuth.bearer, 'token') ?? '' |
| 111 | return { token, type: 'bearer' } |
| 112 | } |
| 113 | |
| 114 | if (type === 'basic') { |
| 115 | return { |
| 116 | password: getKeyValueArrayValue(rawAuth.basic, 'password') ?? '', |
| 117 | type: 'basic', |
| 118 | username: getKeyValueArrayValue(rawAuth.basic, 'username') ?? '', |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | addWarning(warnings, source, `Unsupported auth type "${type}" skipped`) |
| 123 | return { type: 'none' } |
| 124 | } |
| 125 | |
| 126 | function parseHeaders(rawHeaders: unknown): HttpHeaderEntry[] { |
| 127 | return asArray(rawHeaders) |
no test coverage detected