mirror of
https://github.com/fankes/beszel.git
synced 2025-10-21 19:10:38 +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)
|
export const getHostDisplayValue = (system: SystemRecord): string => system.host.slice(system.host.lastIndexOf("/") + 1)
|
||||||
|
|
||||||
/** Generate a random token for the agent */
|
/** 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 */
|
/** Get the hub URL from the global BESZEL object */
|
||||||
export const getHubURL = () => BESZEL?.HUB_URL || window.location.origin
|
export const getHubURL = () => BESZEL?.HUB_URL || window.location.origin
|
||||||
|
Reference in New Issue
Block a user