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

Function buildSessionLabel

src/node/services/serverAuthService.ts:159–181  ·  view source on GitHub ↗
(userAgent: string | undefined)

Source from the content-addressed store, hash-verified

157}
158
159function 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
183function parseGithubDeviceCodeResponse(data: unknown): GithubDeviceCodeResponse | null {
184 if (!data || typeof data !== "object") {

Callers 3

validateSessionTokenMethod · 0.85
listSessionsMethod · 0.85
createSessionLockedMethod · 0.85

Calls 3

normalizeOptionalStringFunction · 0.70

Tested by

no test coverage detected