michangarrito/apps/mcp-server/node_modules/hono/dist/utils/basic-auth.js
rckrdmrd 48dea7a5d0 feat: Initial commit - michangarrito
Marketplace móvil para negocios locales mexicanos.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React Web)
- apps/mobile (Expo/React Native)
- apps/mcp-server (Claude MCP Server)
- apps/whatsapp-service (WhatsApp Business API)
- database/ (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:02 -06:00

24 lines
628 B
JavaScript

// 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
};