Home / Function/ hasValidToken() — vite Function Reference

hasValidToken() — vite Function Reference

Architecture documentation for the hasValidToken() function in ws.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  92168511_91a7_3f51_bfad_0ba065c191e7["hasValidToken()"]
  cab2c96f_4573_f58d_dd64_51e96c3e5033["ws.ts"]
  92168511_91a7_3f51_bfad_0ba065c191e7 -->|defined in| cab2c96f_4573_f58d_dd64_51e96c3e5033
  ed427876_97cc_17d4_d5e4_ae67bba950e3["createWebSocketServer()"]
  ed427876_97cc_17d4_d5e4_ae67bba950e3 -->|calls| 92168511_91a7_3f51_bfad_0ba065c191e7
  style 92168511_91a7_3f51_bfad_0ba065c191e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/ws.ts lines 104–116

function hasValidToken(config: ResolvedConfig, url: URL) {
  const token = url.searchParams.get('token')
  if (!token) return false

  try {
    const isValidToken = crypto.timingSafeEqual(
      Buffer.from(token),
      Buffer.from(config.webSocketToken),
    )
    return isValidToken
  } catch {} // an error is thrown when the length is incorrect
  return false
}

Domain

Subdomains

Frequently Asked Questions

What does hasValidToken() do?
hasValidToken() is a function in the vite codebase, defined in packages/vite/src/node/server/ws.ts.
Where is hasValidToken() defined?
hasValidToken() is defined in packages/vite/src/node/server/ws.ts at line 104.
What calls hasValidToken()?
hasValidToken() is called by 1 function(s): createWebSocketServer.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free