{"version":3,"sources":["jsdelivr-header.js","/npm/@block65/express-aws-cognito@9.0.1/dist/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,qBAAwB,wCACxB,mCAAuC,mCACvC,+BAAkC,2CAClC,mCACF,SAAS,mBAAkB,OAAE,EAAM,WAAE,EAAU,gBAAE,IACpD,MAAM,EAAW,+BAA+B,CAC5C,SACA,aACA,oBAEJ,OAAO,kBAAiB,MAAO,EAAK,EAAK,KACrC,MAAM,EAAc,EAAI,OAAO,kBAAkB,MAAM,MAAQ,IACxD,EAAS,GAAI,EAAM,IAAM,EAChC,IAAK,EACD,MAAM,IAAI,4BACL,UAAU,CACX,WAAY,CACR,CACI,MAAO,gBACP,YAAa,qBAIpB,MAAM,CACP,cACA,SACA,QAGR,GAA6B,WAAzB,EAAO,cACP,MAAM,IAAI,4BACL,UAAU,CACX,WAAY,CACR,CACI,MAAO,gBACP,YAAa,qBAIpB,MAAM,CAAE,cAAa,WAE9B,IAAK,EACD,MAAM,IAAI,4BACL,UAAU,CACX,WAAY,CACR,CACI,MAAO,gBACP,YAAa,2BAIpB,MAAM,CACP,cACA,QAGR,EAAI,OAAO,YAAc,EAAS,GAClC,GAAM,GAEd","file":"/npm/@block65/express-aws-cognito@9.0.1/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@block65/express-aws-cognito@9.0.1/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { expressAsyncWrap } from '@block65/express-async-wrapper';\nimport { awsCognitoTokenVerifierFactory, } from '@block65/aws-cognito-auth';\nimport { InvalidAuthenticationError } from './invalid-authentication-error.js';\nexport { InvalidAuthenticationError };\nexport function expressAwsCognito({ region, userPoolId, userIdGenerator, }) {\n    const verifier = awsCognitoTokenVerifierFactory({\n        region,\n        userPoolId,\n        userIdGenerator,\n    });\n    return expressAsyncWrap(async (req, res, next) => {\n        const headerValue = req.header('authorization')?.split(' ') || [];\n        const [scheme = '', jwt = ''] = headerValue;\n        if (!scheme) {\n            throw new InvalidAuthenticationError()\n                .addDetail({\n                violations: [\n                    {\n                        field: 'authorization',\n                        description: 'Missing scheme',\n                    },\n                ],\n            })\n                .debug({\n                headerValue,\n                scheme,\n                jwt,\n            });\n        }\n        if (scheme.toLowerCase() !== 'bearer') {\n            throw new InvalidAuthenticationError()\n                .addDetail({\n                violations: [\n                    {\n                        field: 'authorization',\n                        description: 'Invalid scheme',\n                    },\n                ],\n            })\n                .debug({ headerValue, scheme });\n        }\n        if (!jwt) {\n            throw new InvalidAuthenticationError()\n                .addDetail({\n                violations: [\n                    {\n                        field: 'authorization',\n                        description: 'Missing bearer token',\n                    },\n                ],\n            })\n                .debug({\n                headerValue,\n                jwt,\n            });\n        }\n        res.locals.token = await verifier(jwt);\n        next();\n    });\n}\n"]}