From 99998a90489b5df29d923ea7bec3bfb0ae2b67ef Mon Sep 17 00:00:00 2001 From: Arnav K Date: Tue, 25 Nov 2025 01:32:42 +0530 Subject: [PATCH] feat: add session token override handling in DevServer - Implemented TOKEN_UPDATED event listener to handle session token updates. - Added private method to manage session token updates and log success or error messages. --- cli/dev/DevServer.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cli/dev/DevServer.ts b/cli/dev/DevServer.ts index 7ad4735c..856cb5c8 100644 --- a/cli/dev/DevServer.ts +++ b/cli/dev/DevServer.ts @@ -20,6 +20,7 @@ import kleur from "kleur" import { loadProjectConfig } from "lib/project-config" import { shouldIgnorePath } from "lib/shared/should-ignore-path" import { getAllNodeModuleFilePaths } from "lib/dependency-analysis/getNodeModuleDependencies" +import { setSessionToken } from "lib/cli-config" const debug = Debug("tscircuit:devserver") @@ -118,6 +119,10 @@ export class DevServer { this.handleInstallPackage(event.full_package_name), ) + this.eventsWatcher.on("TOKEN_UPDATED", (event) => + this.handleTokenUpdated(event.registry_token), + ) + this.filesystemWatcher = chokidar.watch(this.projectDir, { persistent: true, ignoreInitial: true, @@ -488,4 +493,15 @@ export class DevServer { ) } } + + private handleTokenUpdated(registry_token: string) { + try { + setSessionToken(registry_token) + console.log( + kleur.green("Session token overridden successfully via runframe"), + ) + } catch (err) { + console.error("Failed to update session token:", err) + } + } }