(data: unknown)
| 181 | } |
| 182 | |
| 183 | function parseGithubDeviceCodeResponse(data: unknown): GithubDeviceCodeResponse | null { |
| 184 | if (!data || typeof data !== "object") { |
| 185 | return null; |
| 186 | } |
| 187 | |
| 188 | const record = data as Record<string, unknown>; |
| 189 | const verificationUri = normalizeOptionalString(record.verification_uri); |
| 190 | const userCode = normalizeOptionalString(record.user_code); |
| 191 | const deviceCode = normalizeOptionalString(record.device_code); |
| 192 | |
| 193 | if (!verificationUri || !userCode || !deviceCode) { |
| 194 | return null; |
| 195 | } |
| 196 | |
| 197 | const intervalValue = record.interval; |
| 198 | const interval = |
| 199 | typeof intervalValue === "number" && Number.isFinite(intervalValue) && intervalValue > 0 |
| 200 | ? intervalValue |
| 201 | : undefined; |
| 202 | |
| 203 | return { |
| 204 | verification_uri: verificationUri, |
| 205 | user_code: userCode, |
| 206 | device_code: deviceCode, |
| 207 | interval, |
| 208 | }; |
| 209 | } |
| 210 | |
| 211 | function parseGithubAccessTokenResponse(data: unknown): GithubAccessTokenResponse { |
| 212 | if (!data || typeof data !== "object") { |
no test coverage detected