MCPcopy Index your code
hub / github.com/callstack/agent-device / readCliSession

Function readCliSession

src/cli/auth-session.ts:276–294  ·  view source on GitHub ↗
(options: { stateDir: string })

Source from the content-addressed store, hash-verified

274}
275
276export function readCliSession(options: { stateDir: string }): CliSessionRecord | null {
277 const filePath = resolveCliSessionPath(options.stateDir);
278 if (!fs.existsSync(filePath)) return null;
279 try {
280 const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as Partial<CliSessionRecord>;
281 if (
282 parsed.version !== 1 ||
283 !hasToken(parsed.id) ||
284 !hasToken(parsed.cloudBaseUrl) ||
285 !hasToken(parsed.refreshCredential) ||
286 !hasToken(parsed.createdAt)
287 ) {
288 return null;
289 }
290 return parsed as CliSessionRecord;
291 } catch {
292 return null;
293 }
294}
295
296export function writeCliSession(options: { stateDir: string; session: CliSessionRecord }): void {
297 const filePath = resolveCliSessionPath(options.stateDir);

Callers 3

summarizeCliSessionFunction · 0.85
resolveCliSessionAccessFunction · 0.85

Calls 3

resolveCliSessionPathFunction · 0.85
hasTokenFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected