mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 00:05:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,24 +1,27 @@
|
||||
import { storeCreateToken, storeGetUserByToken } from "../store";
|
||||
import { storeCreateToken, storeGetUserByToken } from '../store'
|
||||
|
||||
let tokenCounter = 0;
|
||||
let tokenCounter = 0
|
||||
|
||||
/** Generate a random session token and associate it with a user */
|
||||
export function issueToken(username: string): { token: string; expires_in: number } {
|
||||
export function issueToken(username: string): {
|
||||
token: string
|
||||
expires_in: number
|
||||
} {
|
||||
// Use crypto.getRandomValues for uniqueness
|
||||
const bytes = new Uint8Array(16);
|
||||
crypto.getRandomValues(bytes);
|
||||
const bytes = new Uint8Array(16)
|
||||
crypto.getRandomValues(bytes)
|
||||
const hex = Array.from(bytes)
|
||||
.map((b) => b.toString(16).padStart(2, "0"))
|
||||
.join("");
|
||||
const token = `rct_${tokenCounter++}_${hex}`;
|
||||
storeCreateToken(username, token);
|
||||
return { token, expires_in: 86400 };
|
||||
.map(b => b.toString(16).padStart(2, '0'))
|
||||
.join('')
|
||||
const token = `rct_${tokenCounter++}_${hex}`
|
||||
storeCreateToken(username, token)
|
||||
return { token, expires_in: 86400 }
|
||||
}
|
||||
|
||||
/** Resolve a token to a username. Returns null if invalid. */
|
||||
export function resolveToken(token: string | undefined): string | null {
|
||||
if (!token) return null;
|
||||
const entry = storeGetUserByToken(token);
|
||||
if (!entry) return null;
|
||||
return entry.username;
|
||||
if (!token) return null
|
||||
const entry = storeGetUserByToken(token)
|
||||
if (!entry) return null
|
||||
return entry.username
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user