(userAgent: string | undefined)
| 157 | } |
| 158 | |
| 159 | function buildSessionLabel(userAgent: string | undefined): string { |
| 160 | const normalizedUserAgent = normalizeOptionalString(userAgent); |
| 161 | if (!normalizedUserAgent) { |
| 162 | return "Unknown device"; |
| 163 | } |
| 164 | |
| 165 | const browser = detectBrowserFromUserAgent(normalizedUserAgent); |
| 166 | const device = detectDeviceFromUserAgent(normalizedUserAgent); |
| 167 | |
| 168 | if (browser && device) { |
| 169 | return `${browser} on ${device}`; |
| 170 | } |
| 171 | |
| 172 | if (browser) { |
| 173 | return browser; |
| 174 | } |
| 175 | |
| 176 | if (device) { |
| 177 | return device; |
| 178 | } |
| 179 | |
| 180 | return "Unknown device"; |
| 181 | } |
| 182 | |
| 183 | function parseGithubDeviceCodeResponse(data: unknown): GithubDeviceCodeResponse | null { |
| 184 | if (!data || typeof data !== "object") { |
no test coverage detected