UNPKG

web-crawling-utils

Version:
22 lines (21 loc) 738 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.authenticate = void 0; const auth_1 = require("./auth"); /** * Middleware to verify a JWT token for AWS Lambda. * @param event - The AWS API Gateway Proxy event. * @returns The decoded user info if token is valid. */ const authenticate = (event) => { const authHeader = event.headers['Authorization'] || event.headers['authorization']; if (!authHeader) { throw new Error('Authorization header missing'); } const token = authHeader.split(' ')[1]; // Expecting 'Bearer <token>' if (!token) { throw new Error('Token missing'); } return (0, auth_1.verifyToken)(token); }; exports.authenticate = authenticate;