in app/lib/oauth2Utils.ts [6:27]
export function generateRandomString(length: number): string {
const charset =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
let result = "";
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
// Browser/Node.js with crypto
const randomBytes = new Uint8Array(length);
crypto.getRandomValues(randomBytes);
for (let i = 0; i < length; i++) {
result += charset[randomBytes[i] % charset.length];
}
} else {
// Fallback for older environments
for (let i = 0; i < length; i++) {
result += charset[Math.floor(Math.random() * charset.length)];
}
}
return result;
}