MCPcopy
hub / github.com/coder/mux / parseGithubDeviceCodeResponse

Function parseGithubDeviceCodeResponse

src/node/services/serverAuthService.ts:183–209  ·  view source on GitHub ↗
(data: unknown)

Source from the content-addressed store, hash-verified

181}
182
183function 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
211function parseGithubAccessTokenResponse(data: unknown): GithubAccessTokenResponse {
212 if (!data || typeof data !== "object") {

Callers 1

startGithubDeviceFlowMethod · 0.85

Calls 1

normalizeOptionalStringFunction · 0.70

Tested by

no test coverage detected