MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / refreshSession

Method refreshSession

packages/cloud/src/WebAuthService.ts:434–461  ·  view source on GitHub ↗

* Refresh the session * * This method refreshes the session token using the client token.

()

Source from the content-addressed store, hash-verified

432 * This method refreshes the session token using the client token.
433 */
434 private async refreshSession(): Promise<void> {
435 if (!this.credentials) {
436 this.log("[auth] Cannot refresh session: missing credentials")
437 return
438 }
439
440 try {
441 const previousState = this.state
442 this.sessionToken = await this.clerkCreateSessionToken()
443
444 if (previousState !== "active-session") {
445 this.changeState("active-session")
446 this.fetchUserInfo()
447 } else {
448 this.state = "active-session"
449 }
450 } catch (error) {
451 if (error instanceof InvalidClientTokenError) {
452 this.log("[auth] Invalid/Expired client token: clearing credentials")
453 this.clearCredentials()
454 } else if (this.isFirstRefreshAttempt && this.state === "attempting-session") {
455 this.isFirstRefreshAttempt = false
456 this.transitionToInactiveSession()
457 }
458 this.log("[auth] Failed to refresh session", error)
459 throw error
460 }
461 }
462
463 private async fetchUserInfo(): Promise<void> {
464 if (!this.credentials) {

Callers 1

constructorMethod · 0.95

Calls 6

changeStateMethod · 0.95
fetchUserInfoMethod · 0.95
clearCredentialsMethod · 0.95
logMethod · 0.65

Tested by

no test coverage detected