mirror of
https://github.com/fankes/beszel.git
synced 2025-10-21 10:49:28 +08:00
fix: frontend token generation in insecure contexts
This commit is contained in:
@@ -442,7 +442,13 @@ export const alertInfo: Record<string, AlertInfo> = {
|
||||
export const getHostDisplayValue = (system: SystemRecord): string => system.host.slice(system.host.lastIndexOf("/") + 1)
|
||||
|
||||
/** Generate a random token for the agent */
|
||||
export const generateToken = () => crypto?.randomUUID() ?? (performance.now() * Math.random()).toString(16)
|
||||
export const generateToken = () => {
|
||||
try {
|
||||
return crypto?.randomUUID()
|
||||
} catch (e) {
|
||||
return Array.from({ length: 2 }, () => (performance.now() * Math.random()).toString(16).replace(".", "-")).join("-")
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the hub URL from the global BESZEL object */
|
||||
export const getHubURL = () => BESZEL?.HUB_URL || window.location.origin
|
||||
|
Reference in New Issue
Block a user