Skip to main content
Glama
basic-auth.js628 B
// src/utils/basic-auth.ts import { decodeBase64 } from "./encode.js"; var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/; var USER_PASS_REGEXP = /^([^:]*):(.*)$/; var utf8Decoder = new TextDecoder(); var auth = (req) => { const match = CREDENTIALS_REGEXP.exec(req.headers.get("Authorization") || ""); if (!match) { return void 0; } let userPass = void 0; try { userPass = USER_PASS_REGEXP.exec(utf8Decoder.decode(decodeBase64(match[1]))); } catch { } if (!userPass) { return void 0; } return { username: userPass[1], password: userPass[2] }; }; export { auth };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Valerio357/bet-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server