Spaces:
Configuration error
Configuration error
Download src/security/auth.js from UUUZCX/video-optimizer-bot: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/spaces/UUUZCX/video-optimizer-bot/resolve/main/src/security/auth.js
- Command line
-
hf download hf://spaces/UUUZCX/video-optimizer-bot/src/security/auth.js
-
curl -L -o auth.js https://huggingface.co/spaces/UUUZCX/video-optimizer-bot/resolve/main/src/security/auth.js
655 Bytes
| const crypto = require("node:crypto"); | |
| const { config } = require("../config/env"); | |
| function isAdmin(userId) { | |
| return config.telegram.admins.includes(String(userId)); | |
| } | |
| function isAllowedUser(userId) { | |
| if (isAdmin(userId)) return true; | |
| if (config.telegram.allowPublicUsers) return true; | |
| return config.telegram.allowedUsers.includes(String(userId)); | |
| } | |
| function timingSafeEqualText(a, b) { | |
| const left = Buffer.from(String(a || "")); | |
| const right = Buffer.from(String(b || "")); | |
| if (left.length !== right.length) return false; | |
| return crypto.timingSafeEqual(left, right); | |
| } | |
| module.exports = { isAdmin, isAllowedUser, timingSafeEqualText }; | |