@bitblit/ratchet-epsilon-common 4.0.85-alpha
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/CHANGELOG.md +177 -0
- package/License.txt +13 -0
- package/README.md +242 -0
- package/dist/cjs/background/background-dynamo-log-table-handler.js +38 -0
- package/dist/cjs/background/background-entry.js +2 -0
- package/dist/cjs/background/background-execution-event-type.js +11 -0
- package/dist/cjs/background/background-execution-event.js +2 -0
- package/dist/cjs/background/background-execution-listener.js +2 -0
- package/dist/cjs/background/background-handler.js +269 -0
- package/dist/cjs/background/background-http-adapter-handler.js +127 -0
- package/dist/cjs/background/background-meta-response-internal.js +2 -0
- package/dist/cjs/background/background-process-handling.js +8 -0
- package/dist/cjs/background/background-process-log-table-entry.js +2 -0
- package/dist/cjs/background/background-queue-response-internal.js +2 -0
- package/dist/cjs/background/background-validator.js +88 -0
- package/dist/cjs/background/epsilon-background-process-error.js +93 -0
- package/dist/cjs/background/internal-background-entry.js +2 -0
- package/dist/cjs/background/manager/abstract-background-manager.js +92 -0
- package/dist/cjs/background/manager/aws-sqs-sns-background-manager.js +153 -0
- package/dist/cjs/background/manager/background-manager-like.js +2 -0
- package/dist/cjs/background/manager/single-thread-local-background-manager.js +49 -0
- package/dist/cjs/background/s3-background-transaction-logger.js +54 -0
- package/dist/cjs/build/ratchet-epsilon-common-info.js +18 -0
- package/dist/cjs/built-in/background/echo-processor.js +18 -0
- package/dist/cjs/built-in/background/log-and-enqueue-echo-processor.js +16 -0
- package/dist/cjs/built-in/background/log-message-background-error-processor.js +10 -0
- package/dist/cjs/built-in/background/no-op-processor.js +13 -0
- package/dist/cjs/built-in/background/retry-processor.js +41 -0
- package/dist/cjs/built-in/background/sample-delay-processor.js +16 -0
- package/dist/cjs/built-in/background/sample-input-validated-processor-data.js +2 -0
- package/dist/cjs/built-in/background/sample-input-validated-processor.js +16 -0
- package/dist/cjs/built-in/built-in-trace-id-generators.js +25 -0
- package/dist/cjs/built-in/daemon/daemon-authorizer-function.js +2 -0
- package/dist/cjs/built-in/daemon/daemon-config.js +2 -0
- package/dist/cjs/built-in/daemon/daemon-group-selection-function.js +2 -0
- package/dist/cjs/built-in/daemon/daemon-handler.js +62 -0
- package/dist/cjs/built-in/daemon/daemon-process-state-list.js +2 -0
- package/dist/cjs/built-in/http/apollo-filter.js +63 -0
- package/dist/cjs/built-in/http/built-in-auth-filters.js +115 -0
- package/dist/cjs/built-in/http/built-in-authorizers.js +43 -0
- package/dist/cjs/built-in/http/built-in-filters.js +222 -0
- package/dist/cjs/built-in/http/built-in-handlers.js +73 -0
- package/dist/cjs/built-in/http/log-level-manipulation-filter.js +20 -0
- package/dist/cjs/built-in/http/run-handler-as-filter.js +64 -0
- package/dist/cjs/cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run.js +20 -0
- package/dist/cjs/config/background/background-aws-config.js +2 -0
- package/dist/cjs/config/background/background-config.js +2 -0
- package/dist/cjs/config/background/background-error-processor.js +2 -0
- package/dist/cjs/config/background/background-processor.js +2 -0
- package/dist/cjs/config/background/background-transaction-log.js +2 -0
- package/dist/cjs/config/background/background-transaction-logger.js +2 -0
- package/dist/cjs/config/cron/abstract-cron-entry.js +2 -0
- package/dist/cjs/config/cron/cron-background-entry.js +2 -0
- package/dist/cjs/config/cron/cron-config.js +2 -0
- package/dist/cjs/config/dynamo-db-config.js +2 -0
- package/dist/cjs/config/epsilon-config.js +2 -0
- package/dist/cjs/config/epsilon-lambda-event-handler.js +2 -0
- package/dist/cjs/config/epsilon-logger-config.js +2 -0
- package/dist/cjs/config/generic-aws-event-handler-function.js +2 -0
- package/dist/cjs/config/http/authorizer-function.js +2 -0
- package/dist/cjs/config/http/epsilon-authorization-context.js +2 -0
- package/dist/cjs/config/http/extended-api-gateway-event.js +2 -0
- package/dist/cjs/config/http/filter-chain-context.js +2 -0
- package/dist/cjs/config/http/filter-function.js +2 -0
- package/dist/cjs/config/http/handler-function.js +2 -0
- package/dist/cjs/config/http/http-config.js +2 -0
- package/dist/cjs/config/http/http-processing-config.js +2 -0
- package/dist/cjs/config/http/mapped-http-processing-config.js +2 -0
- package/dist/cjs/config/http/null-returned-object-handling.js +9 -0
- package/dist/cjs/config/inter-api/inter-api-aws-config.js +2 -0
- package/dist/cjs/config/inter-api/inter-api-config.js +2 -0
- package/dist/cjs/config/inter-api/inter-api-process-mapping.js +2 -0
- package/dist/cjs/config/logging-trace-id-generator.js +2 -0
- package/dist/cjs/config/open-api/open-api-document-components.js +2 -0
- package/dist/cjs/config/open-api/open-api-document-path.js +2 -0
- package/dist/cjs/config/open-api/open-api-document.js +2 -0
- package/dist/cjs/config/s3-config.js +2 -0
- package/dist/cjs/config/sns-config.js +2 -0
- package/dist/cjs/epsilon-build-properties.js +28 -0
- package/dist/cjs/epsilon-constants.js +49 -0
- package/dist/cjs/epsilon-global-handler.js +155 -0
- package/dist/cjs/epsilon-instance.js +2 -0
- package/dist/cjs/epsilon-logging-extension-processor.js +19 -0
- package/dist/cjs/http/auth/api-gateway-adapter-authentication-handler.js +75 -0
- package/dist/cjs/http/auth/auth0-web-token-manipulator.js +62 -0
- package/dist/cjs/http/auth/basic-auth-token.js +2 -0
- package/dist/cjs/http/auth/google-web-token-manipulator.js +72 -0
- package/dist/cjs/http/auth/jwt-ratchet-local-web-token-manipulator.js +29 -0
- package/dist/cjs/http/auth/local-web-token-manipulator.js +74 -0
- package/dist/cjs/http/auth/web-token-manipulator.js +2 -0
- package/dist/cjs/http/error/bad-gateway.js +12 -0
- package/dist/cjs/http/error/bad-request-error.js +12 -0
- package/dist/cjs/http/error/conflict-error.js +12 -0
- package/dist/cjs/http/error/epsilon-http-error.js +132 -0
- package/dist/cjs/http/error/forbidden-error.js +12 -0
- package/dist/cjs/http/error/gateway-timeout.js +12 -0
- package/dist/cjs/http/error/method-not-allowed-error.js +12 -0
- package/dist/cjs/http/error/misconfigured-error.js +12 -0
- package/dist/cjs/http/error/not-found-error.js +12 -0
- package/dist/cjs/http/error/not-implemented.js +12 -0
- package/dist/cjs/http/error/request-timeout-error.js +12 -0
- package/dist/cjs/http/error/service-unavailable.js +12 -0
- package/dist/cjs/http/error/too-many-requests-error.js +12 -0
- package/dist/cjs/http/error/unauthorized-error.js +12 -0
- package/dist/cjs/http/event-util.js +180 -0
- package/dist/cjs/http/response-util.js +146 -0
- package/dist/cjs/http/route/epsilon-router.js +2 -0
- package/dist/cjs/http/route/extended-auth-response-context.js +2 -0
- package/dist/cjs/http/route/route-mapping.js +2 -0
- package/dist/cjs/http/route/route-validator-config.js +2 -0
- package/dist/cjs/http/route/router-util.js +238 -0
- package/dist/cjs/http/web-handler.js +122 -0
- package/dist/cjs/http/web-v2-handler.js +25 -0
- package/dist/cjs/index.js +136 -0
- package/dist/cjs/inter-api/inter-api-entry.js +2 -0
- package/dist/cjs/inter-api/inter-api-util.js +62 -0
- package/dist/cjs/inter-api-manager.js +67 -0
- package/dist/cjs/lambda-event-handler/cron-epsilon-lambda-event-handler.js +76 -0
- package/dist/cjs/lambda-event-handler/dynamo-epsilon-lambda-event-handler.js +36 -0
- package/dist/cjs/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.js +32 -0
- package/dist/cjs/lambda-event-handler/inter-api-epsilon-lambda-event-handler.js +26 -0
- package/dist/cjs/lambda-event-handler/s3-epsilon-lambda-event-handler.js +44 -0
- package/dist/cjs/local-container-server.js +79 -0
- package/dist/cjs/local-server-cert.js +71 -0
- package/dist/cjs/local-server.js +145 -0
- package/dist/cjs/open-api-util/open-api-doc-modifications.js +2 -0
- package/dist/cjs/open-api-util/open-api-doc-modifier.js +83 -0
- package/dist/cjs/open-api-util/yaml-combiner.js +32 -0
- package/dist/cjs/run-background-process-from-command-line.js +37 -0
- package/dist/cjs/sample/sample-batch-only-local-server.js +19 -0
- package/dist/cjs/sample/sample-local-server.js +30 -0
- package/dist/cjs/sample/sample-server-components.js +197 -0
- package/dist/cjs/test-error-server.js +48 -0
- package/dist/cjs/util/aws-util.js +69 -0
- package/dist/cjs/util/context-util.js +104 -0
- package/dist/cjs/util/cron-util.js +72 -0
- package/dist/cjs/util/epsilon-config-parser.js +70 -0
- package/dist/es/background/background-dynamo-log-table-handler.js +33 -0
- package/dist/es/background/background-entry.js +1 -0
- package/dist/es/background/background-execution-event-type.js +8 -0
- package/dist/es/background/background-execution-event.js +1 -0
- package/dist/es/background/background-execution-listener.js +1 -0
- package/dist/es/background/background-handler.js +265 -0
- package/dist/es/background/background-http-adapter-handler.js +123 -0
- package/dist/es/background/background-meta-response-internal.js +1 -0
- package/dist/es/background/background-process-handling.js +5 -0
- package/dist/es/background/background-process-log-table-entry.js +1 -0
- package/dist/es/background/background-queue-response-internal.js +1 -0
- package/dist/es/background/background-validator.js +84 -0
- package/dist/es/background/epsilon-background-process-error.js +88 -0
- package/dist/es/background/internal-background-entry.js +1 -0
- package/dist/es/background/manager/abstract-background-manager.js +88 -0
- package/dist/es/background/manager/aws-sqs-sns-background-manager.js +149 -0
- package/dist/es/background/manager/background-manager-like.js +1 -0
- package/dist/es/background/manager/single-thread-local-background-manager.js +45 -0
- package/dist/es/background/s3-background-transaction-logger.js +49 -0
- package/dist/es/build/ratchet-epsilon-common-info.js +14 -0
- package/dist/es/built-in/background/echo-processor.js +14 -0
- package/dist/es/built-in/background/log-and-enqueue-echo-processor.js +12 -0
- package/dist/es/built-in/background/log-message-background-error-processor.js +6 -0
- package/dist/es/built-in/background/no-op-processor.js +9 -0
- package/dist/es/built-in/background/retry-processor.js +36 -0
- package/dist/es/built-in/background/sample-delay-processor.js +12 -0
- package/dist/es/built-in/background/sample-input-validated-processor-data.js +1 -0
- package/dist/es/built-in/background/sample-input-validated-processor.js +12 -0
- package/dist/es/built-in/built-in-trace-id-generators.js +21 -0
- package/dist/es/built-in/daemon/daemon-authorizer-function.js +1 -0
- package/dist/es/built-in/daemon/daemon-config.js +1 -0
- package/dist/es/built-in/daemon/daemon-group-selection-function.js +1 -0
- package/dist/es/built-in/daemon/daemon-handler.js +58 -0
- package/dist/es/built-in/daemon/daemon-process-state-list.js +1 -0
- package/dist/es/built-in/http/apollo-filter.js +58 -0
- package/dist/es/built-in/http/built-in-auth-filters.js +107 -0
- package/dist/es/built-in/http/built-in-authorizers.js +39 -0
- package/dist/es/built-in/http/built-in-filters.js +208 -0
- package/dist/es/built-in/http/built-in-handlers.js +69 -0
- package/dist/es/built-in/http/log-level-manipulation-filter.js +16 -0
- package/dist/es/built-in/http/run-handler-as-filter.js +60 -0
- package/dist/es/cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run.js +17 -0
- package/dist/es/config/background/background-aws-config.js +1 -0
- package/dist/es/config/background/background-config.js +1 -0
- package/dist/es/config/background/background-error-processor.js +1 -0
- package/dist/es/config/background/background-processor.js +1 -0
- package/dist/es/config/background/background-transaction-log.js +1 -0
- package/dist/es/config/background/background-transaction-logger.js +1 -0
- package/dist/es/config/cron/abstract-cron-entry.js +1 -0
- package/dist/es/config/cron/cron-background-entry.js +1 -0
- package/dist/es/config/cron/cron-config.js +1 -0
- package/dist/es/config/dynamo-db-config.js +1 -0
- package/dist/es/config/epsilon-config.js +1 -0
- package/dist/es/config/epsilon-lambda-event-handler.js +1 -0
- package/dist/es/config/epsilon-logger-config.js +1 -0
- package/dist/es/config/generic-aws-event-handler-function.js +1 -0
- package/dist/es/config/http/authorizer-function.js +1 -0
- package/dist/es/config/http/epsilon-authorization-context.js +1 -0
- package/dist/es/config/http/extended-api-gateway-event.js +1 -0
- package/dist/es/config/http/filter-chain-context.js +1 -0
- package/dist/es/config/http/filter-function.js +1 -0
- package/dist/es/config/http/handler-function.js +1 -0
- package/dist/es/config/http/http-config.js +1 -0
- package/dist/es/config/http/http-processing-config.js +1 -0
- package/dist/es/config/http/mapped-http-processing-config.js +1 -0
- package/dist/es/config/http/null-returned-object-handling.js +6 -0
- package/dist/es/config/inter-api/inter-api-aws-config.js +1 -0
- package/dist/es/config/inter-api/inter-api-config.js +1 -0
- package/dist/es/config/inter-api/inter-api-process-mapping.js +1 -0
- package/dist/es/config/logging-trace-id-generator.js +1 -0
- package/dist/es/config/open-api/open-api-document-components.js +1 -0
- package/dist/es/config/open-api/open-api-document-path.js +1 -0
- package/dist/es/config/open-api/open-api-document.js +1 -0
- package/dist/es/config/s3-config.js +1 -0
- package/dist/es/config/sns-config.js +1 -0
- package/dist/es/epsilon-build-properties.js +24 -0
- package/dist/es/epsilon-constants.js +45 -0
- package/dist/es/epsilon-global-handler.js +149 -0
- package/dist/es/epsilon-instance.js +1 -0
- package/dist/es/epsilon-logging-extension-processor.js +15 -0
- package/dist/es/http/auth/api-gateway-adapter-authentication-handler.js +71 -0
- package/dist/es/http/auth/auth0-web-token-manipulator.js +56 -0
- package/dist/es/http/auth/basic-auth-token.js +1 -0
- package/dist/es/http/auth/google-web-token-manipulator.js +67 -0
- package/dist/es/http/auth/jwt-ratchet-local-web-token-manipulator.js +25 -0
- package/dist/es/http/auth/local-web-token-manipulator.js +70 -0
- package/dist/es/http/auth/web-token-manipulator.js +1 -0
- package/dist/es/http/error/bad-gateway.js +8 -0
- package/dist/es/http/error/bad-request-error.js +8 -0
- package/dist/es/http/error/conflict-error.js +8 -0
- package/dist/es/http/error/epsilon-http-error.js +127 -0
- package/dist/es/http/error/forbidden-error.js +8 -0
- package/dist/es/http/error/gateway-timeout.js +8 -0
- package/dist/es/http/error/method-not-allowed-error.js +8 -0
- package/dist/es/http/error/misconfigured-error.js +8 -0
- package/dist/es/http/error/not-found-error.js +8 -0
- package/dist/es/http/error/not-implemented.js +8 -0
- package/dist/es/http/error/request-timeout-error.js +8 -0
- package/dist/es/http/error/service-unavailable.js +8 -0
- package/dist/es/http/error/too-many-requests-error.js +8 -0
- package/dist/es/http/error/unauthorized-error.js +8 -0
- package/dist/es/http/event-util.js +175 -0
- package/dist/es/http/response-util.js +141 -0
- package/dist/es/http/route/epsilon-router.js +1 -0
- package/dist/es/http/route/extended-auth-response-context.js +1 -0
- package/dist/es/http/route/route-mapping.js +1 -0
- package/dist/es/http/route/route-validator-config.js +1 -0
- package/dist/es/http/route/router-util.js +233 -0
- package/dist/es/http/web-handler.js +116 -0
- package/dist/es/http/web-v2-handler.js +21 -0
- package/dist/es/index.js +133 -0
- package/dist/es/inter-api/inter-api-entry.js +1 -0
- package/dist/es/inter-api/inter-api-util.js +58 -0
- package/dist/es/inter-api-manager.js +63 -0
- package/dist/es/lambda-event-handler/cron-epsilon-lambda-event-handler.js +72 -0
- package/dist/es/lambda-event-handler/dynamo-epsilon-lambda-event-handler.js +32 -0
- package/dist/es/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.js +28 -0
- package/dist/es/lambda-event-handler/inter-api-epsilon-lambda-event-handler.js +22 -0
- package/dist/es/lambda-event-handler/s3-epsilon-lambda-event-handler.js +40 -0
- package/dist/es/local-container-server.js +74 -0
- package/dist/es/local-server-cert.js +67 -0
- package/dist/es/local-server.js +140 -0
- package/dist/es/open-api-util/open-api-doc-modifications.js +1 -0
- package/dist/es/open-api-util/open-api-doc-modifier.js +78 -0
- package/dist/es/open-api-util/yaml-combiner.js +27 -0
- package/dist/es/run-background-process-from-command-line.js +32 -0
- package/dist/es/sample/sample-batch-only-local-server.js +17 -0
- package/dist/es/sample/sample-local-server.js +28 -0
- package/dist/es/sample/sample-server-components.js +192 -0
- package/dist/es/test-error-server.js +43 -0
- package/dist/es/util/aws-util.js +65 -0
- package/dist/es/util/context-util.js +95 -0
- package/dist/es/util/cron-util.js +68 -0
- package/dist/es/util/epsilon-config-parser.js +64 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.es.tsbuildinfo +1 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/background/background-dynamo-log-table-handler.d.ts +11 -0
- package/dist/types/background/background-entry.d.ts +4 -0
- package/dist/types/background/background-execution-event-type.d.ts +7 -0
- package/dist/types/background/background-execution-event.d.ts +8 -0
- package/dist/types/background/background-execution-listener.d.ts +5 -0
- package/dist/types/background/background-handler.d.ts +33 -0
- package/dist/types/background/background-http-adapter-handler.d.ts +26 -0
- package/dist/types/background/background-meta-response-internal.d.ts +5 -0
- package/dist/types/background/background-process-handling.d.ts +4 -0
- package/dist/types/background/background-process-log-table-entry.d.ts +11 -0
- package/dist/types/background/background-queue-response-internal.d.ts +8 -0
- package/dist/types/background/background-validator.d.ts +20 -0
- package/dist/types/background/epsilon-background-process-error.d.ts +30 -0
- package/dist/types/background/internal-background-entry.d.ts +7 -0
- package/dist/types/background/manager/abstract-background-manager.d.ts +26 -0
- package/dist/types/background/manager/aws-sqs-sns-background-manager.d.ts +30 -0
- package/dist/types/background/manager/background-manager-like.d.ts +24 -0
- package/dist/types/background/manager/single-thread-local-background-manager.d.ts +22 -0
- package/dist/types/background/s3-background-transaction-logger.d.ts +17 -0
- package/dist/types/build/ratchet-epsilon-common-info.d.ts +5 -0
- package/dist/types/built-in/background/echo-processor.d.ts +7 -0
- package/dist/types/built-in/background/log-and-enqueue-echo-processor.d.ts +6 -0
- package/dist/types/built-in/background/log-message-background-error-processor.d.ts +5 -0
- package/dist/types/built-in/background/no-op-processor.d.ts +6 -0
- package/dist/types/built-in/background/retry-processor.d.ts +16 -0
- package/dist/types/built-in/background/sample-delay-processor.d.ts +6 -0
- package/dist/types/built-in/background/sample-input-validated-processor-data.d.ts +4 -0
- package/dist/types/built-in/background/sample-input-validated-processor.d.ts +8 -0
- package/dist/types/built-in/built-in-trace-id-generators.d.ts +5 -0
- package/dist/types/built-in/daemon/daemon-authorizer-function.d.ts +5 -0
- package/dist/types/built-in/daemon/daemon-config.d.ts +8 -0
- package/dist/types/built-in/daemon/daemon-group-selection-function.d.ts +4 -0
- package/dist/types/built-in/daemon/daemon-handler.d.ts +22 -0
- package/dist/types/built-in/daemon/daemon-process-state-list.d.ts +8 -0
- package/dist/types/built-in/http/apollo-filter.d.ts +10 -0
- package/dist/types/built-in/http/built-in-auth-filters.d.ts +9 -0
- package/dist/types/built-in/http/built-in-authorizers.d.ts +8 -0
- package/dist/types/built-in/http/built-in-filters.d.ts +25 -0
- package/dist/types/built-in/http/built-in-handlers.d.ts +9 -0
- package/dist/types/built-in/http/log-level-manipulation-filter.d.ts +9 -0
- package/dist/types/built-in/http/run-handler-as-filter.d.ts +12 -0
- package/dist/types/cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run.d.ts +2 -0
- package/dist/types/config/background/background-aws-config.d.ts +7 -0
- package/dist/types/config/background/background-config.d.ts +14 -0
- package/dist/types/config/background/background-error-processor.d.ts +4 -0
- package/dist/types/config/background/background-processor.d.ts +6 -0
- package/dist/types/config/background/background-transaction-log.d.ts +8 -0
- package/dist/types/config/background/background-transaction-logger.d.ts +5 -0
- package/dist/types/config/cron/abstract-cron-entry.d.ts +12 -0
- package/dist/types/config/cron/cron-background-entry.d.ts +15 -0
- package/dist/types/config/cron/cron-config.d.ts +6 -0
- package/dist/types/config/dynamo-db-config.d.ts +5 -0
- package/dist/types/config/epsilon-config.d.ts +20 -0
- package/dist/types/config/epsilon-lambda-event-handler.d.ts +7 -0
- package/dist/types/config/epsilon-logger-config.d.ts +12 -0
- package/dist/types/config/generic-aws-event-handler-function.d.ts +3 -0
- package/dist/types/config/http/authorizer-function.d.ts +6 -0
- package/dist/types/config/http/epsilon-authorization-context.d.ts +5 -0
- package/dist/types/config/http/extended-api-gateway-event.d.ts +7 -0
- package/dist/types/config/http/filter-chain-context.d.ts +14 -0
- package/dist/types/config/http/filter-function.d.ts +4 -0
- package/dist/types/config/http/handler-function.d.ts +5 -0
- package/dist/types/config/http/http-config.d.ts +15 -0
- package/dist/types/config/http/http-processing-config.d.ts +11 -0
- package/dist/types/config/http/mapped-http-processing-config.d.ts +7 -0
- package/dist/types/config/http/null-returned-object-handling.d.ts +5 -0
- package/dist/types/config/inter-api/inter-api-aws-config.d.ts +5 -0
- package/dist/types/config/inter-api/inter-api-config.d.ts +6 -0
- package/dist/types/config/inter-api/inter-api-process-mapping.d.ts +11 -0
- package/dist/types/config/logging-trace-id-generator.d.ts +4 -0
- package/dist/types/config/open-api/open-api-document-components.d.ts +4 -0
- package/dist/types/config/open-api/open-api-document-path.d.ts +2 -0
- package/dist/types/config/open-api/open-api-document.d.ts +6 -0
- package/dist/types/config/s3-config.d.ts +6 -0
- package/dist/types/config/sns-config.d.ts +5 -0
- package/dist/types/epsilon-build-properties.d.ts +9 -0
- package/dist/types/epsilon-constants.d.ts +16 -0
- package/dist/types/epsilon-global-handler.d.ts +23 -0
- package/dist/types/epsilon-instance.d.ts +19 -0
- package/dist/types/epsilon-logging-extension-processor.d.ts +5 -0
- package/dist/types/http/auth/api-gateway-adapter-authentication-handler.d.ts +18 -0
- package/dist/types/http/auth/auth0-web-token-manipulator.d.ts +13 -0
- package/dist/types/http/auth/basic-auth-token.d.ts +7 -0
- package/dist/types/http/auth/google-web-token-manipulator.d.ts +14 -0
- package/dist/types/http/auth/jwt-ratchet-local-web-token-manipulator.d.ts +13 -0
- package/dist/types/http/auth/local-web-token-manipulator.d.ts +20 -0
- package/dist/types/http/auth/web-token-manipulator.d.ts +7 -0
- package/dist/types/http/error/bad-gateway.d.ts +5 -0
- package/dist/types/http/error/bad-request-error.d.ts +5 -0
- package/dist/types/http/error/conflict-error.d.ts +5 -0
- package/dist/types/http/error/epsilon-http-error.d.ts +41 -0
- package/dist/types/http/error/forbidden-error.d.ts +5 -0
- package/dist/types/http/error/gateway-timeout.d.ts +5 -0
- package/dist/types/http/error/method-not-allowed-error.d.ts +5 -0
- package/dist/types/http/error/misconfigured-error.d.ts +5 -0
- package/dist/types/http/error/not-found-error.d.ts +5 -0
- package/dist/types/http/error/not-implemented.d.ts +5 -0
- package/dist/types/http/error/request-timeout-error.d.ts +5 -0
- package/dist/types/http/error/service-unavailable.d.ts +5 -0
- package/dist/types/http/error/too-many-requests-error.d.ts +5 -0
- package/dist/types/http/error/unauthorized-error.d.ts +5 -0
- package/dist/types/http/event-util.d.ts +47 -0
- package/dist/types/http/response-util.d.ts +11 -0
- package/dist/types/http/route/epsilon-router.d.ts +8 -0
- package/dist/types/http/route/extended-auth-response-context.d.ts +6 -0
- package/dist/types/http/route/route-mapping.d.ts +12 -0
- package/dist/types/http/route/route-validator-config.d.ts +5 -0
- package/dist/types/http/route/router-util.d.ts +26 -0
- package/dist/types/http/web-handler.d.ts +26 -0
- package/dist/types/http/web-v2-handler.d.ts +13 -0
- package/dist/types/index.d.ts +136 -0
- package/dist/types/inter-api/inter-api-entry.d.ts +7 -0
- package/dist/types/inter-api/inter-api-util.d.ts +10 -0
- package/dist/types/inter-api-manager.d.ts +17 -0
- package/dist/types/lambda-event-handler/cron-epsilon-lambda-event-handler.d.ts +14 -0
- package/dist/types/lambda-event-handler/dynamo-epsilon-lambda-event-handler.d.ts +11 -0
- package/dist/types/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.d.ts +10 -0
- package/dist/types/lambda-event-handler/inter-api-epsilon-lambda-event-handler.d.ts +10 -0
- package/dist/types/lambda-event-handler/s3-epsilon-lambda-event-handler.d.ts +10 -0
- package/dist/types/local-container-server.d.ts +13 -0
- package/dist/types/local-server-cert.d.ts +5 -0
- package/dist/types/local-server.d.ts +19 -0
- package/dist/types/open-api-util/open-api-doc-modifications.d.ts +8 -0
- package/dist/types/open-api-util/open-api-doc-modifier.d.ts +10 -0
- package/dist/types/open-api-util/yaml-combiner.d.ts +3 -0
- package/dist/types/run-background-process-from-command-line.d.ts +13 -0
- package/dist/types/sample/sample-batch-only-local-server.d.ts +1 -0
- package/dist/types/sample/sample-local-server.d.ts +1 -0
- package/dist/types/sample/sample-server-components.d.ts +12 -0
- package/dist/types/test-error-server.d.ts +13 -0
- package/dist/types/util/aws-util.d.ts +8 -0
- package/dist/types/util/context-util.d.ts +33 -0
- package/dist/types/util/cron-util.d.ts +11 -0
- package/dist/types/util/epsilon-config-parser.d.ts +14 -0
- package/package.json +132 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
import { MapRatchet } from '@bitblit/ratchet-common';
|
|
3
|
+
import zlib from 'zlib';
|
|
4
|
+
export class ResponseUtil {
|
|
5
|
+
constructor() { }
|
|
6
|
+
static errorResponse(err) {
|
|
7
|
+
const body = {
|
|
8
|
+
errors: err.errors,
|
|
9
|
+
httpStatusCode: err.httpStatusCode,
|
|
10
|
+
requestId: err.requestId,
|
|
11
|
+
};
|
|
12
|
+
if (err.detailErrorCode) {
|
|
13
|
+
body['detailErrorCode'] = err.detailErrorCode;
|
|
14
|
+
}
|
|
15
|
+
if (err.endUserErrors && err.endUserErrors.length > 0) {
|
|
16
|
+
body['endUserErrors'] = err.endUserErrors;
|
|
17
|
+
}
|
|
18
|
+
if (err.details) {
|
|
19
|
+
body['details'] = err.details;
|
|
20
|
+
}
|
|
21
|
+
if (err.wrappedError) {
|
|
22
|
+
body['wrappedError'] = err.wrappedError.name + ' : ' + err.wrappedError.message;
|
|
23
|
+
}
|
|
24
|
+
const errorResponse = {
|
|
25
|
+
statusCode: err.httpStatusCode,
|
|
26
|
+
isBase64Encoded: false,
|
|
27
|
+
headers: {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify(body),
|
|
31
|
+
};
|
|
32
|
+
return errorResponse;
|
|
33
|
+
}
|
|
34
|
+
static redirect(target, code = 301, queryParams = null) {
|
|
35
|
+
if (code !== 301 && code !== 302 && code !== 307) {
|
|
36
|
+
throw new Error('Code must be 301 or 302 or 307 for a redirect');
|
|
37
|
+
}
|
|
38
|
+
let redirectTarget = target;
|
|
39
|
+
if (queryParams) {
|
|
40
|
+
const keys = Object.keys(queryParams);
|
|
41
|
+
if (keys.length > 0) {
|
|
42
|
+
Logger.silly('Applying params to input target : %j', queryParams);
|
|
43
|
+
redirectTarget += redirectTarget.indexOf('?') === -1 ? '?' : '&';
|
|
44
|
+
for (let i = 0; i < keys.length; i++) {
|
|
45
|
+
const k = keys[i];
|
|
46
|
+
redirectTarget += k + '=' + encodeURIComponent(queryParams[k]);
|
|
47
|
+
if (i < keys.length - 1) {
|
|
48
|
+
redirectTarget += '&';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
statusCode: code,
|
|
55
|
+
body: '{"redirect-target":"' + redirectTarget + '}',
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
Location: redirectTarget,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
static coerceToProxyResult(input) {
|
|
63
|
+
let rval = null;
|
|
64
|
+
if (input != null) {
|
|
65
|
+
if (typeof input === 'object') {
|
|
66
|
+
if (input.statusCode && input.body !== undefined) {
|
|
67
|
+
rval = Object.assign({}, input);
|
|
68
|
+
if (typeof input.body === 'string') {
|
|
69
|
+
}
|
|
70
|
+
else if (Buffer.isBuffer(input.body)) {
|
|
71
|
+
rval.body = input.body.toString('base64');
|
|
72
|
+
rval.headers = input.headers || {};
|
|
73
|
+
rval.headers['Content-Type'] = input.body.contentType;
|
|
74
|
+
rval.isBase64Encoded = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const headers = input.headers || {};
|
|
79
|
+
headers['Content-Type'] = 'application/json';
|
|
80
|
+
rval = ResponseUtil.coerceToProxyResult({
|
|
81
|
+
statusCode: 200,
|
|
82
|
+
body: JSON.stringify(input),
|
|
83
|
+
headers: headers,
|
|
84
|
+
isBase64Encoded: false,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (typeof input === 'string' || Buffer.isBuffer(input)) {
|
|
89
|
+
rval = ResponseUtil.coerceToProxyResult({ statusCode: 200, body: input });
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const headers = input.headers || {};
|
|
93
|
+
headers['Content-Type'] = 'application/json';
|
|
94
|
+
rval = ResponseUtil.coerceToProxyResult({
|
|
95
|
+
statusCode: 200,
|
|
96
|
+
body: JSON.stringify(input),
|
|
97
|
+
headers: headers,
|
|
98
|
+
isBase64Encoded: false,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return rval;
|
|
103
|
+
}
|
|
104
|
+
static async applyGzipIfPossible(encodingHeader, proxyResult) {
|
|
105
|
+
const rval = proxyResult;
|
|
106
|
+
if (encodingHeader && encodingHeader.toLowerCase().indexOf('gzip') > -1) {
|
|
107
|
+
const bigEnough = proxyResult.body.length > 1400;
|
|
108
|
+
let contentType = MapRatchet.extractValueFromMapIgnoreCase(proxyResult.headers, 'content-type') || '';
|
|
109
|
+
contentType = contentType.toLowerCase();
|
|
110
|
+
const exemptContent = contentType === 'application/pdf' || contentType === 'application/zip' || contentType.startsWith('image/');
|
|
111
|
+
if (bigEnough && !exemptContent) {
|
|
112
|
+
const asBuffer = proxyResult.isBase64Encoded ? Buffer.from(proxyResult.body, 'base64') : Buffer.from(proxyResult.body);
|
|
113
|
+
const zipped = await this.gzip(asBuffer);
|
|
114
|
+
Logger.info('Comp from %s to %d bytes', asBuffer.length, zipped.length);
|
|
115
|
+
const zipped64 = zipped.toString('base64');
|
|
116
|
+
rval.body = zipped64;
|
|
117
|
+
rval.isBase64Encoded = true;
|
|
118
|
+
rval.headers = rval.headers || {};
|
|
119
|
+
rval.headers['Content-Encoding'] = 'gzip';
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
Logger.silly('Not gzipping, too small or exempt content');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
Logger.silly('Not gzipping, not an accepted encoding');
|
|
127
|
+
}
|
|
128
|
+
return rval;
|
|
129
|
+
}
|
|
130
|
+
static gzip(input) {
|
|
131
|
+
const promise = new Promise(function (resolve, reject) {
|
|
132
|
+
zlib.gzip(input, function (error, result) {
|
|
133
|
+
if (!error)
|
|
134
|
+
resolve(result);
|
|
135
|
+
else
|
|
136
|
+
reject(error);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return promise;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { MisconfiguredError } from '../error/misconfigured-error';
|
|
2
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
3
|
+
import { BooleanRatchet } from '@bitblit/ratchet-common';
|
|
4
|
+
import { NullReturnedObjectHandling } from '../../config/http/null-returned-object-handling';
|
|
5
|
+
import { BuiltInFilters } from '../../built-in/http/built-in-filters';
|
|
6
|
+
import { BuiltInHandlers } from '../../built-in/http/built-in-handlers';
|
|
7
|
+
import { BuiltInAuthFilters } from '../../built-in/http/built-in-auth-filters';
|
|
8
|
+
import { LogLevelManipulationFilter } from '../../built-in/http/log-level-manipulation-filter';
|
|
9
|
+
export class RouterUtil {
|
|
10
|
+
constructor() { }
|
|
11
|
+
static defaultAuthenticationHeaderParsingEpsilonPreFilters(webTokenManipulator) {
|
|
12
|
+
return [
|
|
13
|
+
(fCtx) => BuiltInAuthFilters.parseAuthorizationHeader(fCtx, webTokenManipulator),
|
|
14
|
+
(fCtx) => BuiltInAuthFilters.applyOpenApiAuthorization(fCtx),
|
|
15
|
+
].concat(RouterUtil.defaultEpsilonPreFilters());
|
|
16
|
+
}
|
|
17
|
+
static defaultEpsilonPreFilters() {
|
|
18
|
+
return [
|
|
19
|
+
(fCtx) => BuiltInFilters.autoRespondToOptionsRequestWithCors(fCtx),
|
|
20
|
+
(fCtx) => BuiltInFilters.ensureEventMaps(fCtx),
|
|
21
|
+
(fCtx) => LogLevelManipulationFilter.setLogLevelForTransaction(fCtx),
|
|
22
|
+
(fCtx) => BuiltInFilters.parseJsonBodyToObject(fCtx),
|
|
23
|
+
(fCtx) => BuiltInFilters.fixStillEncodedQueryParams(fCtx),
|
|
24
|
+
(fCtx) => BuiltInFilters.uriDecodeQueryParams(fCtx),
|
|
25
|
+
(fCtx) => BuiltInFilters.disallowStringNullAsPathParameter(fCtx),
|
|
26
|
+
(fCtx) => BuiltInFilters.disallowStringNullAsQueryStringParameter(fCtx),
|
|
27
|
+
(fCtx) => BuiltInFilters.validateInboundBody(fCtx),
|
|
28
|
+
(fCtx) => BuiltInFilters.validateInboundQueryParams(fCtx),
|
|
29
|
+
(fCtx) => BuiltInFilters.validateInboundQueryParams(fCtx),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
static defaultEpsilonPostFilters() {
|
|
33
|
+
return [
|
|
34
|
+
(fCtx) => BuiltInFilters.validateOutboundResponse(fCtx),
|
|
35
|
+
(fCtx) => BuiltInFilters.addAWSRequestIdHeader(fCtx),
|
|
36
|
+
(fCtx) => BuiltInFilters.addAllowReflectionCORSHeaders(fCtx),
|
|
37
|
+
(fCtx) => BuiltInFilters.applyGzipIfPossible(fCtx),
|
|
38
|
+
(fCtx) => BuiltInFilters.checkMaximumLambdaBodySize(fCtx),
|
|
39
|
+
(fCtx) => LogLevelManipulationFilter.clearLogLevelForTransaction(fCtx),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
static defaultEpsilonErrorFilters() {
|
|
43
|
+
return [
|
|
44
|
+
(fCtx) => BuiltInFilters.addAWSRequestIdHeader(fCtx),
|
|
45
|
+
(fCtx) => BuiltInFilters.addAllowReflectionCORSHeaders(fCtx),
|
|
46
|
+
(fCtx) => LogLevelManipulationFilter.clearLogLevelForTransaction(fCtx),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
static defaultHttpMetaProcessingConfigWithAuthenticationHeaderParsing(webTokenManipulator) {
|
|
50
|
+
const defaults = {
|
|
51
|
+
configName: 'EpsilonDefaultHttpMetaProcessingConfig',
|
|
52
|
+
timeoutMS: 30000,
|
|
53
|
+
overrideAuthorizerName: null,
|
|
54
|
+
preFilters: RouterUtil.defaultAuthenticationHeaderParsingEpsilonPreFilters(webTokenManipulator),
|
|
55
|
+
postFilters: RouterUtil.defaultEpsilonPostFilters(),
|
|
56
|
+
errorFilters: RouterUtil.defaultEpsilonErrorFilters(),
|
|
57
|
+
nullReturnedObjectHandling: NullReturnedObjectHandling.Return404NotFoundResponse,
|
|
58
|
+
};
|
|
59
|
+
return defaults;
|
|
60
|
+
}
|
|
61
|
+
static defaultHttpMetaProcessingConfig() {
|
|
62
|
+
const defaults = {
|
|
63
|
+
configName: 'EpsilonDefaultHttpMetaProcessingConfig',
|
|
64
|
+
timeoutMS: 30000,
|
|
65
|
+
overrideAuthorizerName: null,
|
|
66
|
+
preFilters: RouterUtil.defaultEpsilonPreFilters(),
|
|
67
|
+
postFilters: RouterUtil.defaultEpsilonPostFilters(),
|
|
68
|
+
errorFilters: RouterUtil.defaultEpsilonErrorFilters(),
|
|
69
|
+
nullReturnedObjectHandling: NullReturnedObjectHandling.Return404NotFoundResponse,
|
|
70
|
+
};
|
|
71
|
+
return defaults;
|
|
72
|
+
}
|
|
73
|
+
static assignDefaultsOnHttpConfig(cfg) {
|
|
74
|
+
const defaults = {
|
|
75
|
+
handlers: new Map(),
|
|
76
|
+
authorizers: new Map(),
|
|
77
|
+
defaultMetaHandling: this.defaultHttpMetaProcessingConfig(),
|
|
78
|
+
staticContentRoutes: {},
|
|
79
|
+
prefixesToStripBeforeRouteMatch: [],
|
|
80
|
+
filterHandledRouteMatches: ['options .*'],
|
|
81
|
+
};
|
|
82
|
+
const rval = Object.assign({}, defaults, cfg || {});
|
|
83
|
+
return rval;
|
|
84
|
+
}
|
|
85
|
+
static findApplicableMeta(httpConfig, method, path) {
|
|
86
|
+
let rval = null;
|
|
87
|
+
if (httpConfig?.overrideMetaHandling) {
|
|
88
|
+
for (let i = 0; i < httpConfig.overrideMetaHandling.length && !rval; i++) {
|
|
89
|
+
const test = httpConfig.overrideMetaHandling[i];
|
|
90
|
+
if (!test.methods ||
|
|
91
|
+
test.methods.length === 0 ||
|
|
92
|
+
test.methods.map((s) => s.toLocaleLowerCase()).includes(method.toLocaleLowerCase())) {
|
|
93
|
+
const matches = !!path.match(test.pathRegex);
|
|
94
|
+
if ((matches && !test.invertPathMatching) || (!matches && test.invertPathMatching)) {
|
|
95
|
+
rval = test.config;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!rval) {
|
|
101
|
+
rval = httpConfig.defaultMetaHandling || RouterUtil.defaultHttpMetaProcessingConfig();
|
|
102
|
+
}
|
|
103
|
+
return rval;
|
|
104
|
+
}
|
|
105
|
+
static openApiYamlToRouterConfig(httpConfig, openApiDoc, modelValidator, backgroundHttpAdapterHandler) {
|
|
106
|
+
if (!openApiDoc || !httpConfig) {
|
|
107
|
+
throw new MisconfiguredError('Cannot configure, missing either yaml or cfg');
|
|
108
|
+
}
|
|
109
|
+
const rval = {
|
|
110
|
+
routes: [],
|
|
111
|
+
openApiModelValidator: modelValidator,
|
|
112
|
+
config: RouterUtil.assignDefaultsOnHttpConfig(httpConfig),
|
|
113
|
+
};
|
|
114
|
+
if (openApiDoc?.components?.securitySchemes) {
|
|
115
|
+
Object.keys(openApiDoc.components.securitySchemes).forEach((sk) => {
|
|
116
|
+
if (!rval.config.authorizers || !rval.config.authorizers.get(sk)) {
|
|
117
|
+
throw new MisconfiguredError().withFormattedErrorMessage('Doc requires authorizer %s but not found in map', sk);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const missingPaths = [];
|
|
122
|
+
const filterHandledPathMatches = httpConfig.filterHandledRouteMatches || [];
|
|
123
|
+
if (openApiDoc?.paths) {
|
|
124
|
+
Object.keys(openApiDoc.paths).forEach((path) => {
|
|
125
|
+
Object.keys(openApiDoc.paths[path]).forEach((method) => {
|
|
126
|
+
const convertedPath = RouterUtil.openApiPathToRouteParserPath(path);
|
|
127
|
+
const finder = method + ' ' + path;
|
|
128
|
+
const applicableMeta = RouterUtil.findApplicableMeta(httpConfig, method, path);
|
|
129
|
+
const entry = openApiDoc.paths[path][method];
|
|
130
|
+
const isBackgroundEndpoint = path.startsWith(backgroundHttpAdapterHandler.httpSubmissionPath);
|
|
131
|
+
const isBackgroundMetaEndpoint = path === backgroundHttpAdapterHandler.httpMetaEndpoint;
|
|
132
|
+
const isBackgroundStatusEndpoint = path === backgroundHttpAdapterHandler.httpStatusPath;
|
|
133
|
+
if (isBackgroundEndpoint) {
|
|
134
|
+
rval.config.handlers.set(finder, (evt, ctx) => backgroundHttpAdapterHandler.handleBackgroundSubmission(evt, ctx));
|
|
135
|
+
}
|
|
136
|
+
if (isBackgroundMetaEndpoint) {
|
|
137
|
+
rval.config.handlers.set(finder, (evt, ctx) => backgroundHttpAdapterHandler.handleBackgroundMetaRequest(evt, ctx));
|
|
138
|
+
}
|
|
139
|
+
if (isBackgroundStatusEndpoint) {
|
|
140
|
+
rval.config.handlers.set(finder, (evt, ctx) => backgroundHttpAdapterHandler.handleBackgroundStatusRequest(evt, ctx));
|
|
141
|
+
}
|
|
142
|
+
if (!rval.config.handlers || !rval.config.handlers.get(finder)) {
|
|
143
|
+
const match = filterHandledPathMatches.find((reg) => finder.match(reg));
|
|
144
|
+
if (match) {
|
|
145
|
+
Logger.debug('Adding filter-handled handler for %s', finder);
|
|
146
|
+
rval.config.handlers.set(finder, (evt) => BuiltInHandlers.expectedHandledByFilter(evt));
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
missingPaths.push(finder);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (entry && entry['security'] && entry['security'].length > 1) {
|
|
153
|
+
throw new MisconfiguredError('Epsilon does not currently support multiple security (path was ' + finder + ')');
|
|
154
|
+
}
|
|
155
|
+
const authorizerName = entry['security'] && entry['security'].length == 1 ? Object.keys(entry['security'][0])[0] : null;
|
|
156
|
+
const newRoute = {
|
|
157
|
+
path: convertedPath,
|
|
158
|
+
method: method,
|
|
159
|
+
function: rval.config.handlers.get(finder),
|
|
160
|
+
authorizerName: applicableMeta.overrideAuthorizerName || authorizerName,
|
|
161
|
+
metaProcessingConfig: applicableMeta,
|
|
162
|
+
validation: null,
|
|
163
|
+
outboundValidation: null,
|
|
164
|
+
};
|
|
165
|
+
if (entry['requestBody'] &&
|
|
166
|
+
entry['requestBody']['content'] &&
|
|
167
|
+
entry['requestBody']['content']['application/json'] &&
|
|
168
|
+
entry['requestBody']['content']['application/json']['schema']) {
|
|
169
|
+
const schema = entry['requestBody']['content'];
|
|
170
|
+
Logger.silly('Applying schema %j to %s', schema, finder);
|
|
171
|
+
const modelName = this.findAndValidateModelName(method, path, schema, rval.config.overrideModelValidator || rval.openApiModelValidator);
|
|
172
|
+
const required = BooleanRatchet.parseBool(entry['requestBody']['required']);
|
|
173
|
+
const validation = {
|
|
174
|
+
extraPropertiesAllowed: true,
|
|
175
|
+
emptyAllowed: !required,
|
|
176
|
+
modelName: modelName,
|
|
177
|
+
};
|
|
178
|
+
newRoute.validation = validation;
|
|
179
|
+
}
|
|
180
|
+
if (entry['responses'] &&
|
|
181
|
+
entry['responses']['200'] &&
|
|
182
|
+
entry['responses']['200']['content'] &&
|
|
183
|
+
entry['responses']['200']['content']['application/json'] &&
|
|
184
|
+
entry['responses']['200']['content']['application/json']['schema']) {
|
|
185
|
+
const schema = entry['responses']['200']['content'];
|
|
186
|
+
Logger.silly('Applying schema %j to %s', schema, finder);
|
|
187
|
+
const modelName = this.findAndValidateModelName(method, path, schema, rval.config.overrideModelValidator || rval.openApiModelValidator);
|
|
188
|
+
const validation = {
|
|
189
|
+
extraPropertiesAllowed: false,
|
|
190
|
+
emptyAllowed: false,
|
|
191
|
+
modelName: modelName,
|
|
192
|
+
};
|
|
193
|
+
newRoute.outboundValidation = validation;
|
|
194
|
+
}
|
|
195
|
+
rval.routes.push(newRoute);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (missingPaths.length > 0) {
|
|
200
|
+
throw new MisconfiguredError().withFormattedErrorMessage('Missing expected handlers : %j', missingPaths);
|
|
201
|
+
}
|
|
202
|
+
return rval;
|
|
203
|
+
}
|
|
204
|
+
static findAndValidateModelName(method, path, schema, modelValidator) {
|
|
205
|
+
let rval = undefined;
|
|
206
|
+
const schemaPath = schema['application/json']['schema']['$ref'];
|
|
207
|
+
const inlinePath = schema['application/json']['schema']['type'];
|
|
208
|
+
if (schemaPath) {
|
|
209
|
+
rval = schemaPath.substring(schemaPath.lastIndexOf('/') + 1);
|
|
210
|
+
if (!modelValidator.fetchModel(rval)) {
|
|
211
|
+
throw new MisconfiguredError(`Path ${method} ${path} refers to schema ${rval} but its not in the schema section`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (inlinePath) {
|
|
215
|
+
rval = `${method}-${path}-requestBodyModel`;
|
|
216
|
+
const model = schema['application/json']['schema'];
|
|
217
|
+
modelValidator.addModel(rval, model);
|
|
218
|
+
}
|
|
219
|
+
return rval;
|
|
220
|
+
}
|
|
221
|
+
static openApiPathToRouteParserPath(input) {
|
|
222
|
+
let rval = input;
|
|
223
|
+
if (rval) {
|
|
224
|
+
let sIdx = rval.indexOf('{');
|
|
225
|
+
while (sIdx > -1) {
|
|
226
|
+
const eIdx = rval.indexOf('}');
|
|
227
|
+
rval = rval.substring(0, sIdx) + ':' + rval.substring(sIdx + 1, eIdx) + rval.substring(eIdx + 1);
|
|
228
|
+
sIdx = rval.indexOf('{');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return rval;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
import Route from 'route-parser';
|
|
3
|
+
import { ResponseUtil } from './response-util';
|
|
4
|
+
import { RequireRatchet } from '@bitblit/ratchet-common';
|
|
5
|
+
import { EpsilonHttpError } from './error/epsilon-http-error';
|
|
6
|
+
import { BuiltInFilters } from '../built-in/http/built-in-filters';
|
|
7
|
+
import { RunHandlerAsFilter } from '../built-in/http/run-handler-as-filter';
|
|
8
|
+
import { ContextUtil } from '../util/context-util';
|
|
9
|
+
import { StringRatchet } from '@bitblit/ratchet-common';
|
|
10
|
+
import { LambdaEventDetector } from '@bitblit/ratchet-aws';
|
|
11
|
+
export class WebHandler {
|
|
12
|
+
constructor(routerConfig) {
|
|
13
|
+
this.routerConfig = routerConfig;
|
|
14
|
+
RequireRatchet.notNullOrUndefined(routerConfig);
|
|
15
|
+
}
|
|
16
|
+
get router() {
|
|
17
|
+
return this.routerConfig;
|
|
18
|
+
}
|
|
19
|
+
extractLabel(evt, context) {
|
|
20
|
+
return 'WEB:' + StringRatchet.trimToEmpty(evt.httpMethod).toUpperCase() + ':' + evt.path;
|
|
21
|
+
}
|
|
22
|
+
handlesEvent(evt) {
|
|
23
|
+
return LambdaEventDetector.isValidApiGatewayEvent(evt);
|
|
24
|
+
}
|
|
25
|
+
async processEvent(event, context) {
|
|
26
|
+
if (!this.routerConfig) {
|
|
27
|
+
throw new Error('Router config not found');
|
|
28
|
+
}
|
|
29
|
+
const asExtended = Object.assign({}, { parsedBody: null, authorization: null, convertedFromV2Event: false }, event);
|
|
30
|
+
const rval = await this.openApiLambdaHandler(asExtended, context);
|
|
31
|
+
ContextUtil.addTraceToProxyResult(rval);
|
|
32
|
+
Logger.updateTracePrefix(null);
|
|
33
|
+
return rval;
|
|
34
|
+
}
|
|
35
|
+
async openApiLambdaHandler(evt, context) {
|
|
36
|
+
const rm = this.findBestMatchingRoute(evt);
|
|
37
|
+
const procConfig = rm?.mapping?.metaProcessingConfig
|
|
38
|
+
? rm.mapping.metaProcessingConfig
|
|
39
|
+
: this.routerConfig.config.defaultMetaHandling;
|
|
40
|
+
const fCtx = {
|
|
41
|
+
event: evt,
|
|
42
|
+
context: context,
|
|
43
|
+
result: null,
|
|
44
|
+
rawResult: null,
|
|
45
|
+
routeAndParse: rm,
|
|
46
|
+
modelValidator: this.routerConfig.config.overrideModelValidator || this.routerConfig.openApiModelValidator,
|
|
47
|
+
authenticators: this.routerConfig.config.authorizers,
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
let filterChain = Object.assign([], procConfig.preFilters || []);
|
|
51
|
+
RunHandlerAsFilter.addRunHandlerAsFilterToList(filterChain, rm);
|
|
52
|
+
filterChain = filterChain.concat(procConfig.postFilters || []);
|
|
53
|
+
await BuiltInFilters.combineFilters(fCtx, filterChain);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const wrapper = EpsilonHttpError.wrapError(err);
|
|
57
|
+
fCtx.result = ResponseUtil.errorResponse(wrapper);
|
|
58
|
+
try {
|
|
59
|
+
await BuiltInFilters.combineFilters(fCtx, procConfig.errorFilters);
|
|
60
|
+
}
|
|
61
|
+
catch (convErr) {
|
|
62
|
+
Logger.error('REALLY BAD - FAILED WHILE PROCESSING ERROR FILTERS : %s', convErr);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return fCtx.result;
|
|
66
|
+
}
|
|
67
|
+
findBestMatchingRoute(event) {
|
|
68
|
+
let rval = null;
|
|
69
|
+
const cleanPath = this.cleanPath(event);
|
|
70
|
+
const methodLower = event.httpMethod.toLowerCase();
|
|
71
|
+
const matchRoutes = this.routerConfig.routes
|
|
72
|
+
.map((r) => {
|
|
73
|
+
let rval = null;
|
|
74
|
+
if (r.method && r.method.toLowerCase() === methodLower) {
|
|
75
|
+
const routeParser = new Route(r.path);
|
|
76
|
+
const parsed = routeParser.match(cleanPath);
|
|
77
|
+
if (parsed !== false) {
|
|
78
|
+
rval = {
|
|
79
|
+
mapping: r,
|
|
80
|
+
route: routeParser,
|
|
81
|
+
parsed: parsed,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return rval;
|
|
86
|
+
})
|
|
87
|
+
.filter((r) => r != null);
|
|
88
|
+
matchRoutes.sort((a, b) => {
|
|
89
|
+
return Object.keys(a.parsed).length - Object.keys(b.parsed).length;
|
|
90
|
+
});
|
|
91
|
+
rval = matchRoutes && matchRoutes.length > 0 ? matchRoutes[0] : null;
|
|
92
|
+
if (!rval) {
|
|
93
|
+
Logger.debug('Failed to find handler for %s (cleaned path was %s, strip prefixes were %j)', event.path, cleanPath, this.routerConfig.config.prefixesToStripBeforeRouteMatch);
|
|
94
|
+
}
|
|
95
|
+
return rval;
|
|
96
|
+
}
|
|
97
|
+
cleanPath(event) {
|
|
98
|
+
let rval = event.path;
|
|
99
|
+
while (rval.startsWith('/')) {
|
|
100
|
+
rval = rval.substring(1);
|
|
101
|
+
}
|
|
102
|
+
if (this.routerConfig.config.prefixesToStripBeforeRouteMatch) {
|
|
103
|
+
this.routerConfig.config.prefixesToStripBeforeRouteMatch.forEach((prefix) => {
|
|
104
|
+
if (rval.toLowerCase().startsWith(prefix.toLowerCase() + '/')) {
|
|
105
|
+
rval = rval.substring(prefix.length);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
while (rval.startsWith('/')) {
|
|
110
|
+
rval = rval.substring(1);
|
|
111
|
+
}
|
|
112
|
+
rval = '/' + rval;
|
|
113
|
+
return rval;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
WebHandler.MAXIMUM_LAMBDA_BODY_SIZE_BYTES = 1024 * 1024 * 5 - 1024 * 100;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AwsUtil } from '../util/aws-util';
|
|
2
|
+
import { LambdaEventDetector } from '@bitblit/ratchet-aws';
|
|
3
|
+
export class WebV2Handler {
|
|
4
|
+
constructor(webHandler) {
|
|
5
|
+
this.webHandler = webHandler;
|
|
6
|
+
}
|
|
7
|
+
extractLabel(evt, context) {
|
|
8
|
+
let rval = this.webHandler.extractLabel(AwsUtil.apiGatewayV2ToApiGatewayV1(evt), context);
|
|
9
|
+
rval = rval.replace('WEB:', 'WEB2:');
|
|
10
|
+
return rval;
|
|
11
|
+
}
|
|
12
|
+
handlesEvent(evt) {
|
|
13
|
+
return LambdaEventDetector.isValidApiGatewayV2WithRequestContextEvent(evt);
|
|
14
|
+
}
|
|
15
|
+
async processEvent(evt, context) {
|
|
16
|
+
const conv = AwsUtil.apiGatewayV2ToApiGatewayV1(evt);
|
|
17
|
+
const asExtended = Object.assign({}, { parsedBody: null, authorization: null, convertedFromV2Event: true }, conv);
|
|
18
|
+
const rval = await this.webHandler.openApiLambdaHandler(asExtended, context);
|
|
19
|
+
return rval;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export * from './epsilon-build-properties';
|
|
2
|
+
export * from './epsilon-constants';
|
|
3
|
+
export * from './epsilon-global-handler';
|
|
4
|
+
export * from './epsilon-instance';
|
|
5
|
+
export * from './epsilon-logging-extension-processor';
|
|
6
|
+
export * from './inter-api-manager';
|
|
7
|
+
export * from './local-container-server';
|
|
8
|
+
export * from './local-server-cert';
|
|
9
|
+
export * from './local-server';
|
|
10
|
+
export * from './run-background-process-from-command-line';
|
|
11
|
+
export * from './test-error-server';
|
|
12
|
+
export * from './background/background-dynamo-log-table-handler';
|
|
13
|
+
export * from './background/background-entry';
|
|
14
|
+
export * from './background/background-execution-event-type';
|
|
15
|
+
export * from './background/background-execution-event';
|
|
16
|
+
export * from './background/background-execution-listener';
|
|
17
|
+
export * from './background/background-handler';
|
|
18
|
+
export * from './background/background-http-adapter-handler';
|
|
19
|
+
export * from './background/background-meta-response-internal';
|
|
20
|
+
export * from './background/background-process-handling';
|
|
21
|
+
export * from './background/background-process-log-table-entry';
|
|
22
|
+
export * from './background/background-queue-response-internal';
|
|
23
|
+
export * from './background/background-validator';
|
|
24
|
+
export * from './background/epsilon-background-process-error';
|
|
25
|
+
export * from './background/internal-background-entry';
|
|
26
|
+
export * from './background/s3-background-transaction-logger';
|
|
27
|
+
export * from './background/manager/abstract-background-manager';
|
|
28
|
+
export * from './background/manager/aws-sqs-sns-background-manager';
|
|
29
|
+
export * from './background/manager/background-manager-like';
|
|
30
|
+
export * from './background/manager/single-thread-local-background-manager';
|
|
31
|
+
export * from './build/ratchet-epsilon-common-info';
|
|
32
|
+
export * from './built-in/built-in-trace-id-generators';
|
|
33
|
+
export * from './built-in/background/echo-processor';
|
|
34
|
+
export * from './built-in/background/log-and-enqueue-echo-processor';
|
|
35
|
+
export * from './built-in/background/log-message-background-error-processor';
|
|
36
|
+
export * from './built-in/background/no-op-processor';
|
|
37
|
+
export * from './built-in/background/retry-processor';
|
|
38
|
+
export * from './built-in/background/sample-delay-processor';
|
|
39
|
+
export * from './built-in/background/sample-input-validated-processor-data';
|
|
40
|
+
export * from './built-in/background/sample-input-validated-processor';
|
|
41
|
+
export * from './built-in/daemon/daemon-authorizer-function';
|
|
42
|
+
export * from './built-in/daemon/daemon-config';
|
|
43
|
+
export * from './built-in/daemon/daemon-group-selection-function';
|
|
44
|
+
export * from './built-in/daemon/daemon-handler';
|
|
45
|
+
export * from './built-in/daemon/daemon-process-state-list';
|
|
46
|
+
export * from './built-in/http/apollo-filter';
|
|
47
|
+
export * from './built-in/http/built-in-auth-filters';
|
|
48
|
+
export * from './built-in/http/built-in-authorizers';
|
|
49
|
+
export * from './built-in/http/built-in-filters';
|
|
50
|
+
export * from './built-in/http/built-in-handlers';
|
|
51
|
+
export * from './built-in/http/log-level-manipulation-filter';
|
|
52
|
+
export * from './built-in/http/run-handler-as-filter';
|
|
53
|
+
export * from './cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run';
|
|
54
|
+
export * from './config/dynamo-db-config';
|
|
55
|
+
export * from './config/epsilon-config';
|
|
56
|
+
export * from './config/epsilon-lambda-event-handler';
|
|
57
|
+
export * from './config/epsilon-logger-config';
|
|
58
|
+
export * from './config/generic-aws-event-handler-function';
|
|
59
|
+
export * from './config/logging-trace-id-generator';
|
|
60
|
+
export * from './config/s3-config';
|
|
61
|
+
export * from './config/sns-config';
|
|
62
|
+
export * from './config/background/background-aws-config';
|
|
63
|
+
export * from './config/background/background-config';
|
|
64
|
+
export * from './config/background/background-error-processor';
|
|
65
|
+
export * from './config/background/background-processor';
|
|
66
|
+
export * from './config/background/background-transaction-log';
|
|
67
|
+
export * from './config/background/background-transaction-logger';
|
|
68
|
+
export * from './config/cron/abstract-cron-entry';
|
|
69
|
+
export * from './config/cron/cron-background-entry';
|
|
70
|
+
export * from './config/cron/cron-config';
|
|
71
|
+
export * from './config/http/authorizer-function';
|
|
72
|
+
export * from './config/http/epsilon-authorization-context';
|
|
73
|
+
export * from './config/http/extended-api-gateway-event';
|
|
74
|
+
export * from './config/http/filter-chain-context';
|
|
75
|
+
export * from './config/http/filter-function';
|
|
76
|
+
export * from './config/http/handler-function';
|
|
77
|
+
export * from './config/http/http-config';
|
|
78
|
+
export * from './config/http/http-processing-config';
|
|
79
|
+
export * from './config/http/mapped-http-processing-config';
|
|
80
|
+
export * from './config/http/null-returned-object-handling';
|
|
81
|
+
export * from './config/inter-api/inter-api-aws-config';
|
|
82
|
+
export * from './config/inter-api/inter-api-config';
|
|
83
|
+
export * from './config/inter-api/inter-api-process-mapping';
|
|
84
|
+
export * from './config/open-api/open-api-document-components';
|
|
85
|
+
export * from './config/open-api/open-api-document-path';
|
|
86
|
+
export * from './config/open-api/open-api-document';
|
|
87
|
+
export * from './http/event-util';
|
|
88
|
+
export * from './http/response-util';
|
|
89
|
+
export * from './http/web-handler';
|
|
90
|
+
export * from './http/web-v2-handler';
|
|
91
|
+
export * from './http/auth/api-gateway-adapter-authentication-handler';
|
|
92
|
+
export * from './http/auth/auth0-web-token-manipulator';
|
|
93
|
+
export * from './http/auth/basic-auth-token';
|
|
94
|
+
export * from './http/auth/google-web-token-manipulator';
|
|
95
|
+
export * from './http/auth/jwt-ratchet-local-web-token-manipulator';
|
|
96
|
+
export * from './http/auth/local-web-token-manipulator';
|
|
97
|
+
export * from './http/auth/web-token-manipulator';
|
|
98
|
+
export * from './http/error/bad-gateway';
|
|
99
|
+
export * from './http/error/bad-request-error';
|
|
100
|
+
export * from './http/error/conflict-error';
|
|
101
|
+
export * from './http/error/epsilon-http-error';
|
|
102
|
+
export * from './http/error/forbidden-error';
|
|
103
|
+
export * from './http/error/gateway-timeout';
|
|
104
|
+
export * from './http/error/method-not-allowed-error';
|
|
105
|
+
export * from './http/error/misconfigured-error';
|
|
106
|
+
export * from './http/error/not-found-error';
|
|
107
|
+
export * from './http/error/not-implemented';
|
|
108
|
+
export * from './http/error/request-timeout-error';
|
|
109
|
+
export * from './http/error/service-unavailable';
|
|
110
|
+
export * from './http/error/too-many-requests-error';
|
|
111
|
+
export * from './http/error/unauthorized-error';
|
|
112
|
+
export * from './http/route/epsilon-router';
|
|
113
|
+
export * from './http/route/extended-auth-response-context';
|
|
114
|
+
export * from './http/route/route-mapping';
|
|
115
|
+
export * from './http/route/route-validator-config';
|
|
116
|
+
export * from './http/route/router-util';
|
|
117
|
+
export * from './inter-api/inter-api-entry';
|
|
118
|
+
export * from './inter-api/inter-api-util';
|
|
119
|
+
export * from './lambda-event-handler/cron-epsilon-lambda-event-handler';
|
|
120
|
+
export * from './lambda-event-handler/dynamo-epsilon-lambda-event-handler';
|
|
121
|
+
export * from './lambda-event-handler/generic-sns-epsilon-lambda-event-handler';
|
|
122
|
+
export * from './lambda-event-handler/inter-api-epsilon-lambda-event-handler';
|
|
123
|
+
export * from './lambda-event-handler/s3-epsilon-lambda-event-handler';
|
|
124
|
+
export * from './open-api-util/open-api-doc-modifications';
|
|
125
|
+
export * from './open-api-util/open-api-doc-modifier';
|
|
126
|
+
export * from './open-api-util/yaml-combiner';
|
|
127
|
+
export * from './sample/sample-batch-only-local-server';
|
|
128
|
+
export * from './sample/sample-local-server';
|
|
129
|
+
export * from './sample/sample-server-components';
|
|
130
|
+
export * from './util/aws-util';
|
|
131
|
+
export * from './util/context-util';
|
|
132
|
+
export * from './util/cron-util';
|
|
133
|
+
export * from './util/epsilon-config-parser';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|