@h4ad/serverless-adapter 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +565 -7
- package/lib/@types/binary-settings.d.ts +0 -41
- package/lib/@types/binary-settings.d.ts.map +0 -1
- package/lib/@types/binary-settings.js +0 -2
- package/lib/@types/binary-settings.js.map +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +0 -37
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.js +0 -2
- package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +0 -22
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +0 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.js +0 -2
- package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +0 -1
- package/lib/@types/digital-ocean/index.d.ts +0 -2
- package/lib/@types/digital-ocean/index.d.ts.map +0 -1
- package/lib/@types/digital-ocean/index.js +0 -2
- package/lib/@types/digital-ocean/index.js.map +0 -1
- package/lib/@types/headers.d.ts +0 -37
- package/lib/@types/headers.d.ts.map +0 -1
- package/lib/@types/headers.js +0 -2
- package/lib/@types/headers.js.map +0 -1
- package/lib/@types/helpers.d.ts +0 -10
- package/lib/@types/helpers.d.ts.map +0 -1
- package/lib/@types/helpers.js +0 -2
- package/lib/@types/helpers.js.map +0 -1
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts +0 -81
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +0 -1
- package/lib/@types/huawei/huawei-api-gateway-event.js +0 -2
- package/lib/@types/huawei/huawei-api-gateway-event.js.map +0 -1
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts +0 -27
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +0 -1
- package/lib/@types/huawei/huawei-api-gateway-response.js +0 -2
- package/lib/@types/huawei/huawei-api-gateway-response.js.map +0 -1
- package/lib/@types/huawei/huawei-context.d.ts +0 -188
- package/lib/@types/huawei/huawei-context.d.ts.map +0 -1
- package/lib/@types/huawei/huawei-context.js +0 -2
- package/lib/@types/huawei/huawei-context.js.map +0 -1
- package/lib/@types/huawei/index.d.ts +0 -4
- package/lib/@types/huawei/index.d.ts.map +0 -1
- package/lib/@types/huawei/index.js +0 -2
- package/lib/@types/huawei/index.js.map +0 -1
- package/lib/@types/index.d.ts +0 -4
- package/lib/@types/index.d.ts.map +0 -1
- package/lib/@types/index.js +0 -2
- package/lib/@types/index.js.map +0 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +0 -56
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts.map +0 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +0 -2
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +0 -1
- package/lib/adapters/apollo-server/index.d.ts +0 -2
- package/lib/adapters/apollo-server/index.d.ts.map +0 -1
- package/lib/adapters/apollo-server/index.js +0 -2
- package/lib/adapters/apollo-server/index.js.map +0 -1
- package/lib/adapters/aws/alb.adapter.d.ts +0 -71
- package/lib/adapters/aws/alb.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/alb.adapter.js +0 -2
- package/lib/adapters/aws/alb.adapter.js.map +0 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +0 -76
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.js +0 -2
- package/lib/adapters/aws/api-gateway-v1.adapter.js.map +0 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +0 -75
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.js +0 -2
- package/lib/adapters/aws/api-gateway-v2.adapter.js.map +0 -1
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts +0 -83
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts.map +0 -1
- package/lib/adapters/aws/base/aws-simple-adapter.js +0 -2
- package/lib/adapters/aws/base/aws-simple-adapter.js.map +0 -1
- package/lib/adapters/aws/base/index.d.ts +0 -2
- package/lib/adapters/aws/base/index.d.ts.map +0 -1
- package/lib/adapters/aws/base/index.js +0 -2
- package/lib/adapters/aws/base/index.js.map +0 -1
- package/lib/adapters/aws/dynamodb.adapter.d.ts +0 -56
- package/lib/adapters/aws/dynamodb.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/dynamodb.adapter.js +0 -2
- package/lib/adapters/aws/dynamodb.adapter.js.map +0 -1
- package/lib/adapters/aws/event-bridge.adapter.d.ts +0 -63
- package/lib/adapters/aws/event-bridge.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/event-bridge.adapter.js +0 -2
- package/lib/adapters/aws/event-bridge.adapter.js.map +0 -1
- package/lib/adapters/aws/index.d.ts +0 -12
- package/lib/adapters/aws/index.d.ts.map +0 -1
- package/lib/adapters/aws/index.js +0 -2
- package/lib/adapters/aws/index.js.map +0 -1
- package/lib/adapters/aws/lambda-edge.adapter.d.ts +0 -209
- package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/lambda-edge.adapter.js +0 -2
- package/lib/adapters/aws/lambda-edge.adapter.js.map +0 -1
- package/lib/adapters/aws/request-lambda-edge.adapter.d.ts +0 -131
- package/lib/adapters/aws/request-lambda-edge.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/request-lambda-edge.adapter.js +0 -2
- package/lib/adapters/aws/request-lambda-edge.adapter.js.map +0 -1
- package/lib/adapters/aws/s3.adapter.d.ts +0 -56
- package/lib/adapters/aws/s3.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/s3.adapter.js +0 -2
- package/lib/adapters/aws/s3.adapter.js.map +0 -1
- package/lib/adapters/aws/sns.adapter.d.ts +0 -56
- package/lib/adapters/aws/sns.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/sns.adapter.js +0 -2
- package/lib/adapters/aws/sns.adapter.js.map +0 -1
- package/lib/adapters/aws/sqs.adapter.d.ts +0 -56
- package/lib/adapters/aws/sqs.adapter.d.ts.map +0 -1
- package/lib/adapters/aws/sqs.adapter.js +0 -2
- package/lib/adapters/aws/sqs.adapter.js.map +0 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +0 -81
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts.map +0 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.js +0 -2
- package/lib/adapters/azure/http-trigger-v4.adapter.js.map +0 -1
- package/lib/adapters/azure/index.d.ts +0 -2
- package/lib/adapters/azure/index.d.ts.map +0 -1
- package/lib/adapters/azure/index.js +0 -2
- package/lib/adapters/azure/index.js.map +0 -1
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts +0 -65
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +0 -1
- package/lib/adapters/digital-ocean/http-function.adapter.js +0 -2
- package/lib/adapters/digital-ocean/http-function.adapter.js.map +0 -1
- package/lib/adapters/digital-ocean/index.d.ts +0 -2
- package/lib/adapters/digital-ocean/index.d.ts.map +0 -1
- package/lib/adapters/digital-ocean/index.js +0 -2
- package/lib/adapters/digital-ocean/index.js.map +0 -1
- package/lib/adapters/dummy/dummy.adapter.d.ts +0 -31
- package/lib/adapters/dummy/dummy.adapter.d.ts.map +0 -1
- package/lib/adapters/dummy/dummy.adapter.js +0 -2
- package/lib/adapters/dummy/dummy.adapter.js.map +0 -1
- package/lib/adapters/dummy/index.d.ts +0 -2
- package/lib/adapters/dummy/index.d.ts.map +0 -1
- package/lib/adapters/dummy/index.js +0 -2
- package/lib/adapters/dummy/index.js.map +0 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +0 -66
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +0 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js +0 -2
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +0 -1
- package/lib/adapters/huawei/index.d.ts +0 -2
- package/lib/adapters/huawei/index.d.ts.map +0 -1
- package/lib/adapters/huawei/index.js +0 -2
- package/lib/adapters/huawei/index.js.map +0 -1
- package/lib/contracts/adapter.contract.d.ts +0 -152
- package/lib/contracts/adapter.contract.d.ts.map +0 -1
- package/lib/contracts/adapter.contract.js +0 -2
- package/lib/contracts/adapter.contract.js.map +0 -1
- package/lib/contracts/framework.contract.d.ts +0 -19
- package/lib/contracts/framework.contract.d.ts.map +0 -1
- package/lib/contracts/framework.contract.js +0 -2
- package/lib/contracts/framework.contract.js.map +0 -1
- package/lib/contracts/handler.contract.d.ts +0 -25
- package/lib/contracts/handler.contract.d.ts.map +0 -1
- package/lib/contracts/handler.contract.js +0 -2
- package/lib/contracts/handler.contract.js.map +0 -1
- package/lib/contracts/index.d.ts +0 -5
- package/lib/contracts/index.d.ts.map +0 -1
- package/lib/contracts/index.js +0 -2
- package/lib/contracts/index.js.map +0 -1
- package/lib/contracts/resolver.contract.d.ts +0 -83
- package/lib/contracts/resolver.contract.d.ts.map +0 -1
- package/lib/contracts/resolver.contract.js +0 -2
- package/lib/contracts/resolver.contract.js.map +0 -1
- package/lib/core/base-handler.d.ts +0 -32
- package/lib/core/base-handler.d.ts.map +0 -1
- package/lib/core/base-handler.js +0 -2
- package/lib/core/base-handler.js.map +0 -1
- package/lib/core/constants.d.ts +0 -31
- package/lib/core/constants.d.ts.map +0 -1
- package/lib/core/constants.js +0 -2
- package/lib/core/constants.js.map +0 -1
- package/lib/core/current-invoke.d.ts +0 -48
- package/lib/core/current-invoke.d.ts.map +0 -1
- package/lib/core/current-invoke.js +0 -2
- package/lib/core/current-invoke.js.map +0 -1
- package/lib/core/event-body.d.ts +0 -22
- package/lib/core/event-body.d.ts.map +0 -1
- package/lib/core/event-body.js +0 -2
- package/lib/core/event-body.js.map +0 -1
- package/lib/core/headers.d.ts +0 -73
- package/lib/core/headers.d.ts.map +0 -1
- package/lib/core/headers.js +0 -3
- package/lib/core/headers.js.map +0 -1
- package/lib/core/index.d.ts +0 -12
- package/lib/core/index.d.ts.map +0 -1
- package/lib/core/index.js +0 -2
- package/lib/core/index.js.map +0 -1
- package/lib/core/is-binary.d.ts +0 -73
- package/lib/core/is-binary.d.ts.map +0 -1
- package/lib/core/is-binary.js +0 -2
- package/lib/core/is-binary.js.map +0 -1
- package/lib/core/logger.d.ts +0 -64
- package/lib/core/logger.d.ts.map +0 -1
- package/lib/core/logger.js +0 -2
- package/lib/core/logger.js.map +0 -1
- package/lib/core/no-op.d.ts +0 -8
- package/lib/core/no-op.d.ts.map +0 -1
- package/lib/core/no-op.js +0 -2
- package/lib/core/no-op.js.map +0 -1
- package/lib/core/optional.d.ts +0 -22
- package/lib/core/optional.d.ts.map +0 -1
- package/lib/core/optional.js +0 -2
- package/lib/core/optional.js.map +0 -1
- package/lib/core/path.d.ts +0 -53
- package/lib/core/path.d.ts.map +0 -1
- package/lib/core/path.js +0 -2
- package/lib/core/path.js.map +0 -1
- package/lib/core/stream.d.ts +0 -21
- package/lib/core/stream.d.ts.map +0 -1
- package/lib/core/stream.js +0 -2
- package/lib/core/stream.js.map +0 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +0 -69
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts.map +0 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.js +0 -2
- package/lib/frameworks/apollo-server/apollo-server.framework.js.map +0 -1
- package/lib/frameworks/apollo-server/index.d.ts +0 -2
- package/lib/frameworks/apollo-server/index.d.ts.map +0 -1
- package/lib/frameworks/apollo-server/index.js +0 -2
- package/lib/frameworks/apollo-server/index.js.map +0 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +0 -69
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts.map +0 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.js +0 -2
- package/lib/frameworks/body-parser/base-body-parser.framework.js.map +0 -1
- package/lib/frameworks/body-parser/index.d.ts +0 -6
- package/lib/frameworks/body-parser/index.d.ts.map +0 -1
- package/lib/frameworks/body-parser/index.js +0 -2
- package/lib/frameworks/body-parser/index.js.map +0 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts.map +0 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.js +0 -2
- package/lib/frameworks/body-parser/json-body-parser.framework.js.map +0 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts.map +0 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.js +0 -2
- package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +0 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts.map +0 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.js +0 -2
- package/lib/frameworks/body-parser/text-body-parser.framework.js.map +0 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +0 -26
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts.map +0 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +0 -2
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +0 -1
- package/lib/frameworks/cors/cors.framework.d.ts +0 -78
- package/lib/frameworks/cors/cors.framework.d.ts.map +0 -1
- package/lib/frameworks/cors/cors.framework.js +0 -3
- package/lib/frameworks/cors/cors.framework.js.map +0 -1
- package/lib/frameworks/cors/index.d.ts +0 -2
- package/lib/frameworks/cors/index.d.ts.map +0 -1
- package/lib/frameworks/cors/index.js +0 -2
- package/lib/frameworks/cors/index.js.map +0 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +0 -18
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts.map +0 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.js +0 -2
- package/lib/frameworks/deepkit/http-deepkit.framework.js.map +0 -1
- package/lib/frameworks/deepkit/index.d.ts +0 -2
- package/lib/frameworks/deepkit/index.d.ts.map +0 -1
- package/lib/frameworks/deepkit/index.js +0 -2
- package/lib/frameworks/deepkit/index.js.map +0 -1
- package/lib/frameworks/express/express.framework.d.ts +0 -17
- package/lib/frameworks/express/express.framework.d.ts.map +0 -1
- package/lib/frameworks/express/express.framework.js +0 -2
- package/lib/frameworks/express/express.framework.js.map +0 -1
- package/lib/frameworks/express/index.d.ts +0 -2
- package/lib/frameworks/express/index.d.ts.map +0 -1
- package/lib/frameworks/express/index.js +0 -2
- package/lib/frameworks/express/index.js.map +0 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts +0 -17
- package/lib/frameworks/fastify/fastify.framework.d.ts.map +0 -1
- package/lib/frameworks/fastify/fastify.framework.js +0 -2
- package/lib/frameworks/fastify/fastify.framework.js.map +0 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +0 -14
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts.map +0 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js +0 -2
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +0 -1
- package/lib/frameworks/fastify/index.d.ts +0 -2
- package/lib/frameworks/fastify/index.d.ts.map +0 -1
- package/lib/frameworks/fastify/index.js +0 -2
- package/lib/frameworks/fastify/index.js.map +0 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts +0 -17
- package/lib/frameworks/hapi/hapi.framework.d.ts.map +0 -1
- package/lib/frameworks/hapi/hapi.framework.js +0 -2
- package/lib/frameworks/hapi/hapi.framework.js.map +0 -1
- package/lib/frameworks/hapi/index.d.ts +0 -2
- package/lib/frameworks/hapi/index.d.ts.map +0 -1
- package/lib/frameworks/hapi/index.js +0 -2
- package/lib/frameworks/hapi/index.js.map +0 -1
- package/lib/frameworks/koa/index.d.ts +0 -2
- package/lib/frameworks/koa/index.d.ts.map +0 -1
- package/lib/frameworks/koa/index.js +0 -2
- package/lib/frameworks/koa/index.js.map +0 -1
- package/lib/frameworks/koa/koa.framework.d.ts +0 -17
- package/lib/frameworks/koa/koa.framework.d.ts.map +0 -1
- package/lib/frameworks/koa/koa.framework.js +0 -2
- package/lib/frameworks/koa/koa.framework.js.map +0 -1
- package/lib/frameworks/lazy/index.d.ts +0 -2
- package/lib/frameworks/lazy/index.d.ts.map +0 -1
- package/lib/frameworks/lazy/index.js +0 -2
- package/lib/frameworks/lazy/index.js.map +0 -1
- package/lib/frameworks/lazy/lazy.framework.d.ts +0 -56
- package/lib/frameworks/lazy/lazy.framework.d.ts.map +0 -1
- package/lib/frameworks/lazy/lazy.framework.js +0 -2
- package/lib/frameworks/lazy/lazy.framework.js.map +0 -1
- package/lib/frameworks/trpc/index.d.ts +0 -2
- package/lib/frameworks/trpc/index.d.ts.map +0 -1
- package/lib/frameworks/trpc/index.js +0 -2
- package/lib/frameworks/trpc/index.js.map +0 -1
- package/lib/frameworks/trpc/trpc.framework.d.ts +0 -153
- package/lib/frameworks/trpc/trpc.framework.d.ts.map +0 -1
- package/lib/frameworks/trpc/trpc.framework.js +0 -2
- package/lib/frameworks/trpc/trpc.framework.js.map +0 -1
- package/lib/handlers/aws/aws-stream.handler.d.ts +0 -89
- package/lib/handlers/aws/aws-stream.handler.d.ts.map +0 -1
- package/lib/handlers/aws/aws-stream.handler.js +0 -2
- package/lib/handlers/aws/aws-stream.handler.js.map +0 -1
- package/lib/handlers/aws/index.d.ts +0 -2
- package/lib/handlers/aws/index.d.ts.map +0 -1
- package/lib/handlers/aws/index.js +0 -2
- package/lib/handlers/aws/index.js.map +0 -1
- package/lib/handlers/azure/azure.handler.d.ts +0 -45
- package/lib/handlers/azure/azure.handler.d.ts.map +0 -1
- package/lib/handlers/azure/azure.handler.js +0 -2
- package/lib/handlers/azure/azure.handler.js.map +0 -1
- package/lib/handlers/azure/index.d.ts +0 -2
- package/lib/handlers/azure/index.d.ts.map +0 -1
- package/lib/handlers/azure/index.js +0 -2
- package/lib/handlers/azure/index.js.map +0 -1
- package/lib/handlers/base/index.d.ts +0 -2
- package/lib/handlers/base/index.d.ts.map +0 -1
- package/lib/handlers/base/index.js +0 -2
- package/lib/handlers/base/index.js.map +0 -1
- package/lib/handlers/base/raw-request.d.ts +0 -31
- package/lib/handlers/base/raw-request.d.ts.map +0 -1
- package/lib/handlers/base/raw-request.js +0 -2
- package/lib/handlers/base/raw-request.js.map +0 -1
- package/lib/handlers/default/default.handler.d.ts +0 -88
- package/lib/handlers/default/default.handler.d.ts.map +0 -1
- package/lib/handlers/default/default.handler.js +0 -2
- package/lib/handlers/default/default.handler.js.map +0 -1
- package/lib/handlers/default/index.d.ts +0 -2
- package/lib/handlers/default/index.d.ts.map +0 -1
- package/lib/handlers/default/index.js +0 -2
- package/lib/handlers/default/index.js.map +0 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +0 -17
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +0 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.js +0 -2
- package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +0 -1
- package/lib/handlers/digital-ocean/index.d.ts +0 -2
- package/lib/handlers/digital-ocean/index.d.ts.map +0 -1
- package/lib/handlers/digital-ocean/index.js +0 -2
- package/lib/handlers/digital-ocean/index.js.map +0 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +0 -27
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts.map +0 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.js +0 -2
- package/lib/handlers/firebase/http-firebase-v2.handler.js.map +0 -1
- package/lib/handlers/firebase/http-firebase.handler.d.ts +0 -19
- package/lib/handlers/firebase/http-firebase.handler.d.ts.map +0 -1
- package/lib/handlers/firebase/http-firebase.handler.js +0 -2
- package/lib/handlers/firebase/http-firebase.handler.js.map +0 -1
- package/lib/handlers/firebase/index.d.ts +0 -3
- package/lib/handlers/firebase/index.d.ts.map +0 -1
- package/lib/handlers/firebase/index.js +0 -2
- package/lib/handlers/firebase/index.js.map +0 -1
- package/lib/handlers/gcp/gcp.handler.d.ts +0 -26
- package/lib/handlers/gcp/gcp.handler.d.ts.map +0 -1
- package/lib/handlers/gcp/gcp.handler.js +0 -2
- package/lib/handlers/gcp/gcp.handler.js.map +0 -1
- package/lib/handlers/gcp/index.d.ts +0 -2
- package/lib/handlers/gcp/index.d.ts.map +0 -1
- package/lib/handlers/gcp/index.js +0 -2
- package/lib/handlers/gcp/index.js.map +0 -1
- package/lib/handlers/huawei/http-huawei.handler.d.ts +0 -59
- package/lib/handlers/huawei/http-huawei.handler.d.ts.map +0 -1
- package/lib/handlers/huawei/http-huawei.handler.js +0 -2
- package/lib/handlers/huawei/http-huawei.handler.js.map +0 -1
- package/lib/handlers/huawei/index.d.ts +0 -2
- package/lib/handlers/huawei/index.d.ts.map +0 -1
- package/lib/handlers/huawei/index.js +0 -2
- package/lib/handlers/huawei/index.js.map +0 -1
- package/lib/index.d.ts +0 -6
- package/lib/index.d.ts.map +0 -1
- package/lib/index.doc.js +0 -2
- package/lib/index.doc.js.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/network/index.d.ts +0 -5
- package/lib/network/index.d.ts.map +0 -1
- package/lib/network/index.js +0 -2
- package/lib/network/index.js.map +0 -1
- package/lib/network/request.d.ts +0 -44
- package/lib/network/request.d.ts.map +0 -1
- package/lib/network/request.js +0 -2
- package/lib/network/request.js.map +0 -1
- package/lib/network/response-stream.d.ts +0 -41
- package/lib/network/response-stream.d.ts.map +0 -1
- package/lib/network/response-stream.js +0 -7
- package/lib/network/response-stream.js.map +0 -1
- package/lib/network/response.d.ts +0 -48
- package/lib/network/response.d.ts.map +0 -1
- package/lib/network/response.js +0 -4
- package/lib/network/response.js.map +0 -1
- package/lib/network/utils.d.ts +0 -9
- package/lib/network/utils.d.ts.map +0 -1
- package/lib/network/utils.js +0 -2
- package/lib/network/utils.js.map +0 -1
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts +0 -19
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +0 -1
- package/lib/resolvers/aws-context/aws-context.resolver.js +0 -2
- package/lib/resolvers/aws-context/aws-context.resolver.js.map +0 -1
- package/lib/resolvers/aws-context/index.d.ts +0 -2
- package/lib/resolvers/aws-context/index.d.ts.map +0 -1
- package/lib/resolvers/aws-context/index.js +0 -2
- package/lib/resolvers/aws-context/index.js.map +0 -1
- package/lib/resolvers/callback/callback.resolver.d.ts +0 -23
- package/lib/resolvers/callback/callback.resolver.d.ts.map +0 -1
- package/lib/resolvers/callback/callback.resolver.js +0 -2
- package/lib/resolvers/callback/callback.resolver.js.map +0 -1
- package/lib/resolvers/callback/index.d.ts +0 -2
- package/lib/resolvers/callback/index.d.ts.map +0 -1
- package/lib/resolvers/callback/index.js +0 -2
- package/lib/resolvers/callback/index.js.map +0 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts +0 -14
- package/lib/resolvers/dummy/dummy.resolver.d.ts.map +0 -1
- package/lib/resolvers/dummy/dummy.resolver.js +0 -2
- package/lib/resolvers/dummy/dummy.resolver.js.map +0 -1
- package/lib/resolvers/dummy/index.d.ts +0 -2
- package/lib/resolvers/dummy/index.d.ts.map +0 -1
- package/lib/resolvers/dummy/index.js +0 -2
- package/lib/resolvers/dummy/index.js.map +0 -1
- package/lib/resolvers/promise/index.d.ts +0 -2
- package/lib/resolvers/promise/index.d.ts.map +0 -1
- package/lib/resolvers/promise/index.js +0 -2
- package/lib/resolvers/promise/index.js.map +0 -1
- package/lib/resolvers/promise/promise.resolver.d.ts +0 -14
- package/lib/resolvers/promise/promise.resolver.d.ts.map +0 -1
- package/lib/resolvers/promise/promise.resolver.js +0 -2
- package/lib/resolvers/promise/promise.resolver.js.map +0 -1
- package/lib/serverless-adapter.d.ts +0 -119
- package/lib/serverless-adapter.d.ts.map +0 -1
- package/lib/serverless-adapter.js +0 -2
- package/lib/serverless-adapter.js.map +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { EventBridgeEvent } from 'aws-lambda';
|
|
2
|
-
import { AwsSimpleAdapter } from './base/index';
|
|
3
|
-
/**
|
|
4
|
-
* The options to customize the {@link EventBridgeAdapter}
|
|
5
|
-
*
|
|
6
|
-
* @breadcrumb Adapters / AWS / EventBridgeAdapter
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export interface EventBridgeOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The path that will be used to create a request to be forwarded to the framework.
|
|
12
|
-
*
|
|
13
|
-
* @defaultValue /eventbridge
|
|
14
|
-
*/
|
|
15
|
-
eventBridgeForwardPath?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The http method that will be used to create a request to be forwarded to the framework.
|
|
18
|
-
*
|
|
19
|
-
* @defaultValue POST
|
|
20
|
-
*/
|
|
21
|
-
eventBridgeForwardMethod?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Just a type alias to ignore generic types in the event
|
|
25
|
-
*
|
|
26
|
-
* @breadcrumb Adapters / AWS / EventBridgeAdapter
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export type EventBridgeEventAll = EventBridgeEvent<any, any>;
|
|
30
|
-
/**
|
|
31
|
-
* The adapter to handle requests from AWS EventBridge (Cloudwatch Events).
|
|
32
|
-
*
|
|
33
|
-
* The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
|
|
34
|
-
*
|
|
35
|
-
* {@link https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html | Event Reference}
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const eventBridgeForwardPath = '/your/route/eventbridge'; // default /eventbridge
|
|
40
|
-
* const eventBridgeForwardMethod = 'POST'; // default POST
|
|
41
|
-
* const adapter = new EventBridgeAdapter({ eventBridgeForwardPath, eventBridgeForwardMethod });
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @breadcrumb Adapters / AWS / EventBridgeAdapter
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
export declare class EventBridgeAdapter extends AwsSimpleAdapter<EventBridgeEventAll> {
|
|
48
|
-
/**
|
|
49
|
-
* Default constructor
|
|
50
|
-
*
|
|
51
|
-
* @param options - The options to customize the {@link EventBridgeAdapter}
|
|
52
|
-
*/
|
|
53
|
-
constructor(options?: EventBridgeOptions);
|
|
54
|
-
/**
|
|
55
|
-
* {@inheritDoc}
|
|
56
|
-
*/
|
|
57
|
-
getAdapterName(): string;
|
|
58
|
-
/**
|
|
59
|
-
* {@inheritDoc}
|
|
60
|
-
*/
|
|
61
|
-
canHandle(event: unknown): event is EventBridgeEventAll;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=event-bridge.adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-bridge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/event-bridge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC;IAG3E;;;;OAIG;gBACS,OAAO,CAAC,EAAE,kBAAkB;IAmBxC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB;CAuB/D"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),event_bridge_adapter_exports={};__export(event_bridge_adapter_exports,{EventBridgeAdapter:()=>EventBridgeAdapter});module.exports=__toCommonJS(event_bridge_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class EventBridgeAdapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.eventBridgeForwardPath,"/eventbridge"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.eventBridgeForwardMethod,"POST"),batch:!1,host:"events.amazonaws.com"})}getAdapterName(){return EventBridgeAdapter.name}canHandle(event){const eventBridgeEvent=event;return!!(eventBridgeEvent&&eventBridgeEvent.version&&eventBridgeEvent.version==="0"&&eventBridgeEvent.id&&eventBridgeEvent["detail-type"]&&eventBridgeEvent.source&&eventBridgeEvent.account&&eventBridgeEvent.time&&eventBridgeEvent.region&&eventBridgeEvent.resources&&Array.isArray(eventBridgeEvent.resources)&&eventBridgeEvent.detail&&typeof eventBridgeEvent.detail=="object"&&!Array.isArray(eventBridgeEvent.detail))}}
|
|
2
|
-
//# sourceMappingURL=event-bridge.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-bridge.adapter.js","sources":["../../../src/adapters/aws/event-bridge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { EventBridgeEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link EventBridgeAdapter}\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport interface EventBridgeOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /eventbridge\n */\n eventBridgeForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n eventBridgeForwardMethod?: string;\n}\n\n/**\n * Just a type alias to ignore generic types in the event\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport type EventBridgeEventAll = EventBridgeEvent<any, any>;\n\n/**\n * The adapter to handle requests from AWS EventBridge (Cloudwatch Events).\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html | Event Reference}\n *\n * @example\n * ```typescript\n * const eventBridgeForwardPath = '/your/route/eventbridge'; // default /eventbridge\n * const eventBridgeForwardMethod = 'POST'; // default POST\n * const adapter = new EventBridgeAdapter({ eventBridgeForwardPath, eventBridgeForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport class EventBridgeAdapter extends AwsSimpleAdapter<EventBridgeEventAll> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link EventBridgeAdapter}\n */\n constructor(options?: EventBridgeOptions) {\n super({\n forwardPath: getDefaultIfUndefined(\n options?.eventBridgeForwardPath,\n '/eventbridge',\n ),\n forwardMethod: getDefaultIfUndefined(\n options?.eventBridgeForwardMethod,\n 'POST',\n ),\n batch: false,\n host: 'events.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return EventBridgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is EventBridgeEventAll {\n const eventBridgeEvent = event as Partial<EventBridgeEventAll>;\n\n // thanks to @cnuss in https://github.com/vendia/serverless-express/blob/b5da6070b8dd2fb674c1f7035dd7edfef1dc83a2/src/event-sources/utils.js#L87\n return !!(\n eventBridgeEvent &&\n eventBridgeEvent.version &&\n eventBridgeEvent.version === '0' &&\n eventBridgeEvent.id &&\n eventBridgeEvent['detail-type'] &&\n eventBridgeEvent.source &&\n eventBridgeEvent.account &&\n eventBridgeEvent.time &&\n eventBridgeEvent.region &&\n eventBridgeEvent.resources &&\n Array.isArray(eventBridgeEvent.resources) &&\n eventBridgeEvent.detail &&\n typeof eventBridgeEvent.detail === 'object' &&\n !Array.isArray(eventBridgeEvent.detail)\n );\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,6BAAA,CAAA,EAAA,SAAA,6BAAA,CAAA,mBAAA,IAAA,kBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,4BAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACL,YAAA,QAAA,cAAA,EAmD1B,MAAM,2BAA2B,YAAsC,gBAAA,CAQ5E,YAAY,QAA8B,CAClC,MAAA,CACJ,eAAa,YAAA,uBACX,6BAAS,uBACT,cACF,EACA,iBAAe,YAAA,uBACb,6BAAS,yBACT,MACF,EACA,MAAO,GACP,KAAM,sBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,mBAAmB,IAC5B,CAKO,UAAU,MAA8C,CAC7D,MAAM,iBAAmB,MAGzB,MAAO,CAAC,EACN,kBACA,iBAAiB,SACjB,iBAAiB,UAAY,KAC7B,iBAAiB,IACjB,iBAAiB,aAAa,GAC9B,iBAAiB,QACjB,iBAAiB,SACjB,iBAAiB,MACjB,iBAAiB,QACjB,iBAAiB,WACjB,MAAM,QAAQ,iBAAiB,SAAS,GACxC,iBAAiB,QACjB,OAAO,iBAAiB,QAAW,UACnC,CAAC,MAAM,QAAQ,iBAAiB,MAAM,EAE1C,CAGF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './alb.adapter';
|
|
2
|
-
export * from './api-gateway-v1.adapter';
|
|
3
|
-
export * from './api-gateway-v2.adapter';
|
|
4
|
-
export * from './dynamodb.adapter';
|
|
5
|
-
export * from './event-bridge.adapter';
|
|
6
|
-
export * from './lambda-edge.adapter';
|
|
7
|
-
export * from './s3.adapter';
|
|
8
|
-
export * from './sns.adapter';
|
|
9
|
-
export * from './sqs.adapter';
|
|
10
|
-
export * from './base';
|
|
11
|
-
export * from './request-lambda-edge.adapter';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,+BAA+B,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),aws_exports={};module.exports=__toCommonJS(aws_exports);__reExport(aws_exports,require("./alb.adapter"),module.exports);__reExport(aws_exports,require("./api-gateway-v1.adapter"),module.exports);__reExport(aws_exports,require("./api-gateway-v2.adapter"),module.exports);__reExport(aws_exports,require("./dynamodb.adapter"),module.exports);__reExport(aws_exports,require("./event-bridge.adapter"),module.exports);__reExport(aws_exports,require("./lambda-edge.adapter"),module.exports);__reExport(aws_exports,require("./s3.adapter"),module.exports);__reExport(aws_exports,require("./sns.adapter"),module.exports);__reExport(aws_exports,require("./sqs.adapter"),module.exports);__reExport(aws_exports,require("./base"),module.exports);__reExport(aws_exports,require("./request-lambda-edge.adapter"),module.exports);
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/adapters/aws/index.ts"],"sourcesContent":["export * from './alb.adapter';\nexport * from './api-gateway-v1.adapter';\nexport * from './api-gateway-v2.adapter';\nexport * from './dynamodb.adapter';\nexport * from './event-bridge.adapter';\nexport * from './lambda-edge.adapter';\nexport * from './s3.adapter';\nexport * from './sns.adapter';\nexport * from './sqs.adapter';\nexport * from './base';\nexport * from './request-lambda-edge.adapter';\n"],"names":[],"mappings":"kqBAAA,YAAA,CAAA,EAAA,OAAA,QAAA,aAAA,WAAA,EAAA,WAAA,YAAc,QAAd,eAAA,EAAA,OAAA,OAAA,EACA,WAAA,YAAc,QADd,0BAAA,EAAA,OAAA,OAAA,EAEA,WAAA,YAAc,QAFd,0BAAA,EAAA,OAAA,OAAA,EAGA,WAAA,YAAc,QAHd,oBAAA,EAAA,OAAA,OAAA,EAIA,WAAA,YAAc,QAJd,wBAAA,EAAA,OAAA,OAAA,EAKA,WAAA,YAAc,QALd,uBAAA,EAAA,OAAA,OAAA,EAMA,WAAA,YAAc,QANd,cAAA,EAAA,OAAA,OAAA,EAOA,WAAA,YAAc,QAPd,eAAA,EAAA,OAAA,OAAA,EAQA,WAAA,YAAc,QARd,eAAA,EAAA,OAAA,OAAA,EASA,WAAA,YAAc,QATd,QAAA,EAAA,OAAA,OAAA,EAUA,WAAA,YAAc,QAVd,+BAAA,EAAA,OAAA,OAAA"}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import type { CloudFrontRequest, Context } from 'aws-lambda';
|
|
2
|
-
import type { CloudFrontEvent, CloudFrontHeaders } from 'aws-lambda/common/cloudfront';
|
|
3
|
-
import type { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda/trigger/cloudfront-request';
|
|
4
|
-
import { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';
|
|
5
|
-
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
6
|
-
/**
|
|
7
|
-
* The type alias to indicate where we get the default value of query string to create the request.
|
|
8
|
-
*
|
|
9
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export type DefaultQueryString = CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];
|
|
13
|
-
/**
|
|
14
|
-
* The type alias to indicate where we get the default value of path to create the request.
|
|
15
|
-
*
|
|
16
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export type DefaultForwardPath = CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];
|
|
20
|
-
/**
|
|
21
|
-
* Represents the body of the new version of Lambda\@edge, which uses the `body` property inside `request` as the body (library) of the request.
|
|
22
|
-
*
|
|
23
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export type NewLambdaEdgeBody = CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];
|
|
27
|
-
/**
|
|
28
|
-
* Represents the body of the old version of Lambda\@edge supported by \@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.
|
|
29
|
-
*
|
|
30
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
export type OldLambdaEdgeBody = Concrete<CloudFrontRequestEvent['Records'][number]['cf']['request']>['body']['data'];
|
|
34
|
-
/**
|
|
35
|
-
* The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the "Disallowed Headers" section.
|
|
36
|
-
*
|
|
37
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export declare const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[];
|
|
41
|
-
/**
|
|
42
|
-
* The default max response size in bytes of viewer request and viewer response.
|
|
43
|
-
*
|
|
44
|
-
* @defaultValue 1024 * 40 = 40960 = 40KB
|
|
45
|
-
*
|
|
46
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
47
|
-
*
|
|
48
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES: number;
|
|
52
|
-
/**
|
|
53
|
-
* The default max response size in bytes of origin request and origin response.
|
|
54
|
-
*
|
|
55
|
-
* @defaultValue 1024 * 1024 = 1048576 = 1MB
|
|
56
|
-
*
|
|
57
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
58
|
-
*
|
|
59
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
export declare const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES: number;
|
|
63
|
-
/**
|
|
64
|
-
* The options to customize the {@link LambdaEdgeAdapter}.
|
|
65
|
-
*
|
|
66
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export interface LambdaEdgeAdapterOptions {
|
|
70
|
-
/**
|
|
71
|
-
* The max response size in bytes of viewer request and viewer response.
|
|
72
|
-
*
|
|
73
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
74
|
-
*
|
|
75
|
-
* @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}
|
|
76
|
-
*/
|
|
77
|
-
viewerMaxResponseSizeInBytes?: number;
|
|
78
|
-
/**
|
|
79
|
-
* The max response size in bytes of origin request and origin response.
|
|
80
|
-
*
|
|
81
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
82
|
-
*
|
|
83
|
-
* @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}
|
|
84
|
-
*/
|
|
85
|
-
originMaxResponseSizeInBytes?: number;
|
|
86
|
-
/**
|
|
87
|
-
* The function called when the response size exceed the max limits of the Lambda\@edge
|
|
88
|
-
*
|
|
89
|
-
* @param response - The response from framework that exceed the limit of Lambda\@edge
|
|
90
|
-
* @defaultValue undefined
|
|
91
|
-
*/
|
|
92
|
-
onResponseSizeExceedLimit?: (response: CloudFrontRequestResult) => CloudFrontRequestResult;
|
|
93
|
-
/**
|
|
94
|
-
* Return the path to be used to create a request to the framework
|
|
95
|
-
*
|
|
96
|
-
* @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.
|
|
97
|
-
*
|
|
98
|
-
* @param event - The event sent by the serverless
|
|
99
|
-
* @defaultValue The value from {@link DefaultForwardPath}
|
|
100
|
-
*/
|
|
101
|
-
getPathFromEvent?: (event: CloudFrontRequestEvent['Records'][number]) => string;
|
|
102
|
-
/**
|
|
103
|
-
* The headers that will be stripped from the headers object because Lambda\@edge will fail if these headers are passed in the response.
|
|
104
|
-
*
|
|
105
|
-
* @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)
|
|
106
|
-
*
|
|
107
|
-
* @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.
|
|
108
|
-
*/
|
|
109
|
-
disallowedHeaders?: (string | RegExp)[];
|
|
110
|
-
/**
|
|
111
|
-
* If you want to change how we check against the header if it should be stripped, you can pass a function to this property.
|
|
112
|
-
*
|
|
113
|
-
* @param header - The header of the response
|
|
114
|
-
* @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.
|
|
115
|
-
*/
|
|
116
|
-
shouldStripHeader?: (header: string) => boolean;
|
|
117
|
-
/**
|
|
118
|
-
* By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.
|
|
119
|
-
* So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.
|
|
120
|
-
* Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.
|
|
121
|
-
*
|
|
122
|
-
* @defaultValue false
|
|
123
|
-
*/
|
|
124
|
-
shouldUseHeadersFromFramework?: boolean;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* The adapter to handle requests from AWS Lambda\@Edge.
|
|
128
|
-
*
|
|
129
|
-
* This adapter is not fully compatible with Lambda\@edge supported by \@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.
|
|
130
|
-
* Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.
|
|
131
|
-
* And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.
|
|
132
|
-
*
|
|
133
|
-
* {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}
|
|
134
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```typescript
|
|
138
|
-
* const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint
|
|
139
|
-
* const adapter = new LambdaEdgeAdapter({ getPathFromEvent });
|
|
140
|
-
* ```
|
|
141
|
-
*
|
|
142
|
-
* @breadcrumb Adapters / AWS / LambdaEdgeAdapter
|
|
143
|
-
* @public
|
|
144
|
-
*/
|
|
145
|
-
export declare class LambdaEdgeAdapter implements AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult> {
|
|
146
|
-
protected readonly options?: LambdaEdgeAdapterOptions | undefined;
|
|
147
|
-
/**
|
|
148
|
-
* Default constructor
|
|
149
|
-
*
|
|
150
|
-
* @param options - The options to customize the {@link LambdaEdgeAdapter}
|
|
151
|
-
*/
|
|
152
|
-
constructor(options?: LambdaEdgeAdapterOptions | undefined);
|
|
153
|
-
/**
|
|
154
|
-
* This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.
|
|
155
|
-
*/
|
|
156
|
-
protected readonly cachedDisallowedHeaders: RegExp[];
|
|
157
|
-
/**
|
|
158
|
-
* {@inheritDoc}
|
|
159
|
-
*/
|
|
160
|
-
getAdapterName(): string;
|
|
161
|
-
/**
|
|
162
|
-
* {@inheritDoc}
|
|
163
|
-
*/
|
|
164
|
-
canHandle(event: unknown): event is CloudFrontRequestEvent;
|
|
165
|
-
/**
|
|
166
|
-
* {@inheritDoc}
|
|
167
|
-
*/
|
|
168
|
-
getRequest(event: CloudFrontRequestEvent): AdapterRequest;
|
|
169
|
-
/**
|
|
170
|
-
* {@inheritDoc}
|
|
171
|
-
*/
|
|
172
|
-
getResponse(props: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult;
|
|
173
|
-
/**
|
|
174
|
-
* {@inheritDoc}
|
|
175
|
-
*/
|
|
176
|
-
onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void;
|
|
177
|
-
/**
|
|
178
|
-
* Returns the headers with the flattened (non-list) values of the cloudfront request headers
|
|
179
|
-
*
|
|
180
|
-
* @param cloudFrontRequest - The cloudfront request
|
|
181
|
-
*/
|
|
182
|
-
protected getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest: CloudFrontRequest): SingleValueHeaders;
|
|
183
|
-
/**
|
|
184
|
-
* Returns the framework response in the format required by the Lambda\@edge.
|
|
185
|
-
*
|
|
186
|
-
* @param body - The body of the response
|
|
187
|
-
* @param frameworkHeaders - The headers from the framework
|
|
188
|
-
*/
|
|
189
|
-
protected getResponseToLambdaEdge({ body, headers: frameworkHeaders, }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult;
|
|
190
|
-
/**
|
|
191
|
-
* Returns headers in Cloudfront Response format.
|
|
192
|
-
*
|
|
193
|
-
* @param originalHeaders - The original version of the request sent by the framework
|
|
194
|
-
*/
|
|
195
|
-
protected getHeadersForCloudfrontResponse(originalHeaders: BothValueHeaders): CloudFrontHeaders;
|
|
196
|
-
/**
|
|
197
|
-
* Returns the information if we should remove the response header
|
|
198
|
-
*
|
|
199
|
-
* @param headerKey - The header that will be tested
|
|
200
|
-
*/
|
|
201
|
-
protected shouldStripHeader(headerKey: string): boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Determines whether the event is from origin or is from viewer.
|
|
204
|
-
*
|
|
205
|
-
* @param content - The event sent by AWS or the response sent by the framework
|
|
206
|
-
*/
|
|
207
|
-
protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean;
|
|
208
|
-
}
|
|
209
|
-
//# sourceMappingURL=lambda-edge.adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-edge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAElB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,YAAY,EACb,MAAM,iBAAiB,CAAC;AASzB;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC5B,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC5B,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAC3B,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CACtC,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAC3D,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CA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AAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,cAAc;IA6ChE;;OAEG;IACI,WAAW,CAChB,KAAK,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GACrD,uBAAuB;IAgC1B;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,GAClB,EAAE,YAAY,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,GAAG,IAAI;IAQvE;;;;OAIG;IACH,SAAS,CAAC,wCAAwC,CAChD,iBAAiB,EAAE,iBAAiB,GACnC,kBAAkB;IAUrB;;;;;OAKG;IACH,SAAS,CAAC,uBAAuB,CAAC,EAChC,IAAI,EACJ,OAAO,EAAE,gBAAgB,GAC1B,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,uBAAuB;IA6B5E;;;;OAIG;IACH,SAAS,CAAC,+BAA+B,CACvC,eAAe,EAAE,gBAAgB,GAChC,iBAAiB;IA4BpB;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAevD;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,OAAO;CAKzE"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),lambda_edge_adapter_exports={};__export(lambda_edge_adapter_exports,{DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS:()=>DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES:()=>DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES:()=>DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,LambdaEdgeAdapter:()=>LambdaEdgeAdapter});module.exports=__toCommonJS(lambda_edge_adapter_exports);var import_core=require("../../core");const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS=["Connection","Expect","Keep-Alive","Proxy-Authenticate","Proxy-Authorization","Proxy-Connection","Trailer","Upgrade","X-Accel-Buffering","X-Accel-Charset","X-Accel-Limit-Rate","X-Accel-Redirect",/(X-Amz-Cf-)(.*)/gim,"X-Cache",/(X-Edge-)(.*)/gim,"X-Forwarded-Proto","X-Real-IP"],DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES=1024*40,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES=1024*1024;class LambdaEdgeAdapter{constructor(options){var _a;this.options=options;const disallowedHeaders=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.disallowedHeaders,DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS);this.cachedDisallowedHeaders=disallowedHeaders.map(disallowedHeader=>disallowedHeader instanceof RegExp?disallowedHeader:new RegExp(`(${disallowedHeader})`,"gim"))}getAdapterName(){return LambdaEdgeAdapter.name}canHandle(event){var _a,_b,_c;const lambdaEdgeEvent=event;if(!Array.isArray(lambdaEdgeEvent==null?void 0:lambdaEdgeEvent.Records))return!1;const eventType=(_c=(_b=(_a=lambdaEdgeEvent.Records[0])==null?void 0:_a.cf)==null?void 0:_b.config)==null?void 0:_c.eventType;return["origin-response","origin-request","viewer-response","viewer-request"].includes(eventType)}getRequest(event){var _a;const request=event.Records[0],cloudFrontRequest=request.cf.request,method=cloudFrontRequest.method,pathFromOptions=(_a=this.options)!=null&&_a.getPathFromEvent?this.options.getPathFromEvent(request):void 0,defaultPath=(0,import_core.getPathWithQueryStringParams)(cloudFrontRequest.uri,cloudFrontRequest.querystring),path=(0,import_core.getDefaultIfUndefined)(pathFromOptions,defaultPath),remoteAddress=cloudFrontRequest.clientIp,headers=this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);let body;if(cloudFrontRequest.body){const[buffer,contentLength]=(0,import_core.getEventBodyAsBuffer)(JSON.stringify(cloudFrontRequest.body),!1);body=buffer,headers["content-length"]=contentLength.toString()}const{host}=headers;return{method,path,headers,body,remoteAddress,host,hostname:host}}getResponse(props){var _a,_b,_c;const response=this.getResponseToLambdaEdge(props),responseToServiceBytes=new TextEncoder().encode(JSON.stringify(response)).length,maxSizeInBytes=this.isEventTypeOrigin(props.event.Records[0].cf.config)?(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.originMaxResponseSizeInBytes,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES):(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.viewerMaxResponseSizeInBytes,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES);return responseToServiceBytes<=maxSizeInBytes||((_c=this.options)!=null&&_c.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(response):props.log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`)),response}onErrorWhileForwarding({error,delegatedResolver}){delegatedResolver.fail(error)}getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest){return Object.keys(cloudFrontRequest.headers).reduce((acc,headerKey)=>{const headerValue=cloudFrontRequest.headers[headerKey];return acc[headerKey]=headerValue.map(header=>header.value).join(","),acc},{})}getResponseToLambdaEdge({body,headers:frameworkHeaders}){var _a;const shouldUseHeadersFromFramework=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.shouldUseHeadersFromFramework,!1),parsedBody=JSON.parse(body);return parsedBody.headers&&(parsedBody.headers=Object.keys(parsedBody.headers).reduce((acc,header)=>(this.shouldStripHeader(header)||(acc[header]=parsedBody.headers[header]),acc),{})),shouldUseHeadersFromFramework&&(parsedBody.headers=this.getHeadersForCloudfrontResponse(frameworkHeaders)),parsedBody}getHeadersForCloudfrontResponse(originalHeaders){return Object.keys(originalHeaders).reduce((acc,headerKey)=>{if(this.shouldStripHeader(headerKey))return acc;acc[headerKey]||(acc[headerKey]=[]);const headerValue=originalHeaders[headerKey];if(!Array.isArray(headerValue))return acc[headerKey].push({key:headerKey,value:headerValue||""}),acc;const headersArray=headerValue.map(value=>({key:headerKey,value}));return acc[headerKey].push(...headersArray),acc},{})}shouldStripHeader(headerKey){var _a;if((_a=this.options)!=null&&_a.shouldStripHeader)return this.options.shouldStripHeader(headerKey);const headerKeyLowerCase=headerKey.toLowerCase();for(const stripHeaderIf of this.cachedDisallowedHeaders)if(stripHeaderIf.test(headerKeyLowerCase))return!0;return!1}isEventTypeOrigin(content){return content.eventType.includes("origin")}}
|
|
2
|
-
//# sourceMappingURL=lambda-edge.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-edge.adapter.js","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontEvent,\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\n\n//#endregion\n\n/**\n * The type alias to indicate where we get the default value of query string to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultQueryString =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];\n\n/**\n * The type alias to indicate where we get the default value of path to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultForwardPath =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];\n\n/**\n * Represents the body of the new version of Lambda\\@edge, which uses the `body` property inside `request` as the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type NewLambdaEdgeBody =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];\n\n/**\n * Represents the body of the old version of Lambda\\@edge supported by \\@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type OldLambdaEdgeBody = Concrete<\n CloudFrontRequestEvent['Records'][number]['cf']['request']\n>['body']['data'];\n\n/**\n * The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the \"Disallowed Headers\" section.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[] = [\n 'Connection',\n 'Expect',\n 'Keep-Alive',\n 'Proxy-Authenticate',\n 'Proxy-Authorization',\n 'Proxy-Connection',\n 'Trailer',\n 'Upgrade',\n 'X-Accel-Buffering',\n 'X-Accel-Charset',\n 'X-Accel-Limit-Rate',\n 'X-Accel-Redirect',\n /(X-Amz-Cf-)(.*)/gim,\n 'X-Cache',\n /(X-Edge-)(.*)/gim,\n 'X-Forwarded-Proto',\n 'X-Real-IP',\n];\n\n/**\n * The default max response size in bytes of viewer request and viewer response.\n *\n * @defaultValue 1024 * 40 = 40960 = 40KB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 40;\n\n/**\n * The default max response size in bytes of origin request and origin response.\n *\n * @defaultValue 1024 * 1024 = 1048576 = 1MB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 1024;\n\n/**\n * The options to customize the {@link LambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport interface LambdaEdgeAdapterOptions {\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * Return the path to be used to create a request to the framework\n *\n * @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.\n *\n * @param event - The event sent by the serverless\n * @defaultValue The value from {@link DefaultForwardPath}\n */\n getPathFromEvent?: (\n event: CloudFrontRequestEvent['Records'][number],\n ) => string;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n\n /**\n * By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.\n * So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.\n * Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.\n *\n * @defaultValue false\n */\n shouldUseHeadersFromFramework?: boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge.\n *\n * This adapter is not fully compatible with Lambda\\@edge supported by \\@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.\n * Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.\n * And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint\n * const adapter = new LambdaEdgeAdapter({ getPathFromEvent });\n * ```\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport class LambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link LambdaEdgeAdapter}\n */\n constructor(protected readonly options?: LambdaEdgeAdapterOptions) {\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return LambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n const validEventTypes: CloudFrontEvent['config']['eventType'][] = [\n 'origin-response',\n 'origin-request',\n 'viewer-response',\n 'viewer-request',\n ];\n\n return validEventTypes.includes(eventType);\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const pathFromOptions = this.options?.getPathFromEvent\n ? this.options.getPathFromEvent(request)\n : undefined;\n const defaultPath = getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n );\n const path = getDefaultIfUndefined(pathFromOptions, defaultPath);\n\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n JSON.stringify(cloudFrontRequest.body),\n false,\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse(\n props: GetResponseAdapterProps<CloudFrontRequestEvent>,\n ): CloudFrontRequestResult {\n const response = this.getResponseToLambdaEdge(props);\n const responseToServiceBytes = new TextEncoder().encode(\n JSON.stringify(response),\n ).length;\n\n const isOriginRequestOrResponse = this.isEventTypeOrigin(\n props.event.Records[0].cf.config,\n );\n const maxSizeInBytes = isOriginRequestOrResponse\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n if (responseToServiceBytes <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n props.log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n delegatedResolver.fail(error);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns the framework response in the format required by the Lambda\\@edge.\n *\n * @param body - The body of the response\n * @param frameworkHeaders - The headers from the framework\n */\n protected getResponseToLambdaEdge({\n body,\n headers: frameworkHeaders,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult {\n const shouldUseHeadersFromFramework = getDefaultIfUndefined(\n this.options?.shouldUseHeadersFromFramework,\n false,\n );\n\n const parsedBody: CloudFrontResultResponse | CloudFrontRequest =\n JSON.parse(body);\n\n if (parsedBody.headers) {\n parsedBody.headers = Object.keys(parsedBody.headers).reduce(\n (acc, header) => {\n if (this.shouldStripHeader(header)) return acc;\n\n acc[header] = parsedBody.headers![header];\n\n return acc;\n },\n {} as CloudFrontHeaders,\n );\n }\n\n if (!shouldUseHeadersFromFramework) return parsedBody;\n\n parsedBody.headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n return parsedBody;\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n if (!acc[headerKey]) acc[headerKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[headerKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[headerKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Determines whether the event is from origin or is from viewer.\n *\n * @param content - The event sent by AWS or the response sent by the framework\n */\n protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean {\n return content.eventType.includes('origin');\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,4BAAA,CAAA,EAAA,SAAA,4BAAA,CAAA,uCAAA,IAAA,uCAAA,0CAAA,IAAA,0CAAA,0CAAA,IAAA,0CAAA,kBAAA,IAAA,iBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,2BAAA,EAmBA,IAIO,YAAA,QAAA,YAAA,EA+CA,MAAM,uCAA8D,CACzE,aACA,SACA,aACA,qBACA,sBACA,mBACA,UACA,UACA,oBACA,kBACA,qBACA,mBACA,qBACA,UACA,mBACA,oBACA,WACF,EAYa,0CAA4C,KAAO,GAYnD,0CAA4C,KAAO,KA+FzD,MAAM,iBAGb,CAQE,YAA+B,QAAoC,QAApC,KAAA,QAAA,QAC7B,MAAM,qBAAoB,YAAA,wBACxB,QAAK,UAAL,eAAc,kBACd,sCAAA,EAGG,KAAA,wBAA0B,kBAAkB,IAAwB,kBACnE,4BAA4B,OAAe,iBAExC,IAAI,OAAO,IAAI,gBAAgB,IAAK,KAAK,CACjD,CACH,CAkBO,gBAAyB,CAC9B,OAAO,kBAAkB,IAC3B,CAKO,UAAU,MAAiD,cAChE,MAAM,gBAAkB,MAExB,GAAI,CAAC,MAAM,QAAQ,6CAAiB,OAAO,EAAU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E3C,MAAA,mBAAqB,UAAU,cAE1B,UAAA,iBAAiB,KAAK,wBAC3B,GAAC,cAAc,KAAK,kBAAkB,EAEnC,MAAA,GAGF,MAAA,EACT,CAOU,kBAAkB,QAA6C,CAChE,OAAA,QAAQ,UAAU,SAAS,QAAQ,CAC5C,CAGF"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { CloudFrontRequest, Context } from 'aws-lambda';
|
|
2
|
-
import type { CloudFrontHeaders, CloudFrontResultResponse } from 'aws-lambda/common/cloudfront';
|
|
3
|
-
import type { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda/trigger/cloudfront-request';
|
|
4
|
-
import { BothValueHeaders, SingleValueHeaders } from '../../@types';
|
|
5
|
-
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
6
|
-
import { StripBasePathFn } from '../../core';
|
|
7
|
-
/**
|
|
8
|
-
* The options to customize the {@link RequestLambdaEdgeAdapter}.
|
|
9
|
-
*
|
|
10
|
-
* @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export interface RequestLambdaEdgeAdapterOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Strip base path for custom paths, like `/api`.
|
|
16
|
-
*
|
|
17
|
-
* @defaultValue ''
|
|
18
|
-
*/
|
|
19
|
-
stripBasePath?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The max response size in bytes of viewer request and viewer response.
|
|
22
|
-
*
|
|
23
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
24
|
-
*
|
|
25
|
-
* @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}
|
|
26
|
-
*/
|
|
27
|
-
viewerMaxResponseSizeInBytes?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The max response size in bytes of origin request and origin response.
|
|
30
|
-
*
|
|
31
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
32
|
-
*
|
|
33
|
-
* @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}
|
|
34
|
-
*/
|
|
35
|
-
originMaxResponseSizeInBytes?: number;
|
|
36
|
-
/**
|
|
37
|
-
* The function called when the response size exceed the max limits of the Lambda\@edge
|
|
38
|
-
*
|
|
39
|
-
* @param response - The response from framework that exceed the limit of Lambda\@edge
|
|
40
|
-
* @defaultValue undefined
|
|
41
|
-
*/
|
|
42
|
-
onResponseSizeExceedLimit?: (response: CloudFrontRequestResult) => CloudFrontRequestResult;
|
|
43
|
-
/**
|
|
44
|
-
* The headers that will be stripped from the headers object because Lambda\@edge will fail if these headers are passed in the response.
|
|
45
|
-
*
|
|
46
|
-
* @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)
|
|
47
|
-
*
|
|
48
|
-
* @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.
|
|
49
|
-
*/
|
|
50
|
-
disallowedHeaders?: (string | RegExp)[];
|
|
51
|
-
/**
|
|
52
|
-
* If you want to change how we check against the header if it should be stripped, you can pass a function to this property.
|
|
53
|
-
*
|
|
54
|
-
* @param header - The header of the response
|
|
55
|
-
* @defaultValue The default method is implemented to test the header against the list {@link RequestLambdaEdgeAdapterOptions.disallowedHeaders}.
|
|
56
|
-
*/
|
|
57
|
-
shouldStripHeader?: (header: string) => boolean;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The adapter to handle requests from AWS Lambda\@Edge of the type Viewer Request.
|
|
61
|
-
*
|
|
62
|
-
* The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront.
|
|
63
|
-
*
|
|
64
|
-
* {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}
|
|
65
|
-
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const stripBasePath = '/api'; // in case you have configure the cloudfront to forward the path /api to your lambda
|
|
70
|
-
* const adapter = new RequestLambdaEdgeAdapter({ stripBasePath });
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export declare class RequestLambdaEdgeAdapter implements AdapterContract<CloudFrontRequestEvent, Context, CloudFrontResultResponse> {
|
|
77
|
-
protected readonly options?: RequestLambdaEdgeAdapterOptions | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Default constructor
|
|
80
|
-
*
|
|
81
|
-
* @param options - The options to customize the {@link RequestLambdaEdgeAdapter}
|
|
82
|
-
*/
|
|
83
|
-
constructor(options?: RequestLambdaEdgeAdapterOptions | undefined);
|
|
84
|
-
/**
|
|
85
|
-
* Strip base path function
|
|
86
|
-
*/
|
|
87
|
-
protected readonly stripPathFn: StripBasePathFn;
|
|
88
|
-
/**
|
|
89
|
-
* This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.
|
|
90
|
-
*/
|
|
91
|
-
protected readonly cachedDisallowedHeaders: RegExp[];
|
|
92
|
-
/**
|
|
93
|
-
* {@inheritDoc}
|
|
94
|
-
*/
|
|
95
|
-
getAdapterName(): string;
|
|
96
|
-
/**
|
|
97
|
-
* {@inheritDoc}
|
|
98
|
-
*/
|
|
99
|
-
canHandle(event: unknown): event is CloudFrontRequestEvent;
|
|
100
|
-
/**
|
|
101
|
-
* {@inheritDoc}
|
|
102
|
-
*/
|
|
103
|
-
getRequest(event: CloudFrontRequestEvent): AdapterRequest;
|
|
104
|
-
/**
|
|
105
|
-
* {@inheritDoc}
|
|
106
|
-
*/
|
|
107
|
-
getResponse({ body, headers: frameworkHeaders, isBase64Encoded, statusCode, log, event, }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontResultResponse;
|
|
108
|
-
/**
|
|
109
|
-
* {@inheritDoc}
|
|
110
|
-
*/
|
|
111
|
-
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, log, event, }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void;
|
|
112
|
-
/**
|
|
113
|
-
* Returns the headers with the flattened (non-list) values of the cloudfront request headers
|
|
114
|
-
*
|
|
115
|
-
* @param cloudFrontRequest - The cloudfront request
|
|
116
|
-
*/
|
|
117
|
-
protected getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest: CloudFrontRequest): SingleValueHeaders;
|
|
118
|
-
/**
|
|
119
|
-
* Returns headers in Cloudfront Response format.
|
|
120
|
-
*
|
|
121
|
-
* @param originalHeaders - The original version of the request sent by the framework
|
|
122
|
-
*/
|
|
123
|
-
protected getHeadersForCloudfrontResponse(originalHeaders: BothValueHeaders): CloudFrontHeaders;
|
|
124
|
-
/**
|
|
125
|
-
* Returns the information if we should remove the response header
|
|
126
|
-
*
|
|
127
|
-
* @param headerKey - The header that will be tested
|
|
128
|
-
*/
|
|
129
|
-
protected shouldStripHeader(headerKey: string): boolean;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=request-lambda-edge.adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-lambda-edge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/request-lambda-edge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,sBAAsB,EACtB,uB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ChE;;OAEG;IACI,WAAW,CAAC,EACjB,IAAI,EACJ,OAAO,EAAE,gBAAgB,EACzB,eAAe,EACf,UAAU,EACV,GAAG,EACH,KAAK,GACN,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,wBAAwB;IAqC7E;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,GAAG,EACH,KAAK,GACN,EAAE,YAAY,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,GAAG,IAAI;IAkBvE;;;;OAIG;IACH,SAAS,CAAC,wCAAwC,CAChD,iBAAiB,EAAE,iBAAiB,GACnC,kBAAkB;IAWrB;;;;OAIG;IACH,SAAS,CAAC,+BAA+B,CACvC,eAAe,EAAE,gBAAgB,GAChC,iBAAiB;IA8BpB;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAgBxD"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),request_lambda_edge_adapter_exports={};__export(request_lambda_edge_adapter_exports,{RequestLambdaEdgeAdapter:()=>RequestLambdaEdgeAdapter});module.exports=__toCommonJS(request_lambda_edge_adapter_exports);var import_core=require("../../core"),import_lambda_edge=require("./lambda-edge.adapter");class RequestLambdaEdgeAdapter{constructor(options){var _a,_b;this.options=options,this.stripPathFn=(0,import_core.buildStripBasePath)((_a=this.options)==null?void 0:_a.stripBasePath);const disallowedHeaders=(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.disallowedHeaders,import_lambda_edge.DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS);this.cachedDisallowedHeaders=disallowedHeaders.map(disallowedHeader=>disallowedHeader instanceof RegExp?disallowedHeader:new RegExp(`(${disallowedHeader})`,"gim"))}getAdapterName(){return RequestLambdaEdgeAdapter.name}canHandle(event){var _a,_b,_c;const lambdaEdgeEvent=event;if(!Array.isArray(lambdaEdgeEvent==null?void 0:lambdaEdgeEvent.Records))return!1;const eventType=(_c=(_b=(_a=lambdaEdgeEvent.Records[0])==null?void 0:_a.cf)==null?void 0:_b.config)==null?void 0:_c.eventType;return eventType==="viewer-request"||eventType==="origin-request"}getRequest(event){const cloudFrontRequest=event.Records[0].cf.request,method=cloudFrontRequest.method,path=this.stripPathFn((0,import_core.getPathWithQueryStringParams)(cloudFrontRequest.uri,cloudFrontRequest.querystring)),remoteAddress=cloudFrontRequest.clientIp,headers=this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);let body;if(cloudFrontRequest.body){const[buffer,contentLength]=(0,import_core.getEventBodyAsBuffer)(cloudFrontRequest.body.data,cloudFrontRequest.body.encoding==="base64");body=buffer,headers["content-length"]=contentLength.toString()}const{host}=headers;return{method,path,headers,body,remoteAddress,host,hostname:host}}getResponse({body,headers:frameworkHeaders,isBase64Encoded,statusCode,log,event}){var _a,_b,_c;const headers=this.getHeadersForCloudfrontResponse(frameworkHeaders),maxSizeInBytes=event.Records[0].cf.config.eventType==="origin-request"?(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.originMaxResponseSizeInBytes,import_lambda_edge.DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES):(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.viewerMaxResponseSizeInBytes,import_lambda_edge.DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES),response={body,status:statusCode.toString(),bodyEncoding:isBase64Encoded?"base64":"text",headers},bodyLength=body.length;return bodyLength<=maxSizeInBytes||((_c=this.options)!=null&&_c.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(response):log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${bodyLength} of the max of ${maxSizeInBytes}.`)),response}onErrorWhileForwarding({error,delegatedResolver,respondWithErrors,log,event}){const body=respondWithErrors?error.stack:"",errorResponse=this.getResponse({event,statusCode:500,body:body||"",headers:{},isBase64Encoded:!1,log});delegatedResolver.succeed(errorResponse)}getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest){return Object.keys(cloudFrontRequest.headers).reduce((acc,headerKey)=>{const headerValue=cloudFrontRequest.headers[headerKey];return headerValue.length===1?acc[headerKey]=headerValue[0].value:acc[headerKey]=headerValue.map(header=>header.value).join(","),acc},{})}getHeadersForCloudfrontResponse(originalHeaders){return Object.keys(originalHeaders).reduce((acc,headerKey)=>{if(this.shouldStripHeader(headerKey))return acc;const lowercaseHeaderKey=headerKey.toLowerCase();acc[lowercaseHeaderKey]||(acc[lowercaseHeaderKey]=[]);const headerValue=originalHeaders[headerKey];if(!Array.isArray(headerValue))return acc[lowercaseHeaderKey].push({key:headerKey,value:headerValue||""}),acc;const headersArray=headerValue.map(value=>({key:headerKey,value}));return acc[lowercaseHeaderKey].push(...headersArray),acc},{})}shouldStripHeader(headerKey){var _a;if((_a=this.options)!=null&&_a.shouldStripHeader)return this.options.shouldStripHeader(headerKey);const headerKeyLowerCase=headerKey.toLowerCase();for(const stripHeaderIf of this.cachedDisallowedHeaders)if(stripHeaderIf.test(headerKeyLowerCase))return!0;return!1}}
|
|
2
|
-
//# sourceMappingURL=request-lambda-edge.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-lambda-edge.adapter.js","sources":["../../../src/adapters/aws/request-lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n StripBasePathFn,\n buildStripBasePath,\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\nimport {\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n} from './lambda-edge.adapter';\n\n//#endregion\n\n//#endregion\n\n/**\n * The options to customize the {@link RequestLambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter\n * @public\n */\nexport interface RequestLambdaEdgeAdapterOptions {\n /**\n * Strip base path for custom paths, like `/api`.\n *\n * @defaultValue ''\n */\n stripBasePath?: string;\n\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link RequestLambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge of the type Viewer Request.\n *\n * The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const stripBasePath = '/api'; // in case you have configure the cloudfront to forward the path /api to your lambda\n * const adapter = new RequestLambdaEdgeAdapter({ stripBasePath });\n * ```\n *\n * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter\n * @public\n */\nexport class RequestLambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontResultResponse>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link RequestLambdaEdgeAdapter}\n */\n constructor(protected readonly options?: RequestLambdaEdgeAdapterOptions) {\n this.stripPathFn = buildStripBasePath(this.options?.stripBasePath);\n\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * Strip base path function\n */\n protected readonly stripPathFn: StripBasePathFn;\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return RequestLambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n\n return eventType === 'viewer-request' || eventType === 'origin-request';\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const path = this.stripPathFn(\n getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n ),\n );\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n cloudFrontRequest.body.data,\n cloudFrontRequest.body.encoding === 'base64',\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse({\n body,\n headers: frameworkHeaders,\n isBase64Encoded,\n statusCode,\n log,\n event,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontResultResponse {\n const headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n const maxSizeInBytes =\n event.Records[0].cf.config.eventType === 'origin-request'\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n const response: CloudFrontResultResponse = {\n body,\n status: statusCode.toString(),\n bodyEncoding: isBase64Encoded ? 'base64' : 'text',\n headers,\n };\n\n // probably is not correctly accurate, but it's a good approximation\n const bodyLength = body.length;\n\n if (bodyLength <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${bodyLength} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n respondWithErrors,\n log,\n event,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n const body = respondWithErrors ? error.stack : '';\n const errorResponse = this.getResponse({\n event,\n statusCode: 500,\n body: body || '',\n headers: {},\n isBase64Encoded: false,\n log,\n });\n\n delegatedResolver.succeed(errorResponse);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n if (headerValue.length === 1) acc[headerKey] = headerValue[0].value;\n else acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n const lowercaseHeaderKey = headerKey.toLowerCase();\n\n if (!acc[lowercaseHeaderKey]) acc[lowercaseHeaderKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[lowercaseHeaderKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[lowercaseHeaderKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,oCAAA,CAAA,EAAA,SAAA,oCAAA,CAAA,yBAAA,IAAA,wBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,mCAAA,EAkBA,IAMO,YAAA,QAAA,YAAA,EAKA,mBAAA,QAAA,uBAAA,EAmFA,MAAM,wBAGb,CAQE,YAA+B,QAA2C,WAA3C,KAAA,QAAA,QAC7B,KAAK,eAAc,YAAA,qBAAmB,QAAK,UAAL,eAAc,aAAa,EAEjE,MAAM,qBAAoB,YAAA,wBACxB,QAAK,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