@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,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApolloFilter = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_common_2 = require("@bitblit/ratchet-common");
|
|
6
|
+
const ratchet_common_3 = require("@bitblit/ratchet-common");
|
|
7
|
+
const request_timeout_error_1 = require("../../http/error/request-timeout-error");
|
|
8
|
+
const ratchet_common_4 = require("@bitblit/ratchet-common");
|
|
9
|
+
class ApolloFilter {
|
|
10
|
+
static async handlePathWithApollo(fCtx, apolloPathRegex, apolloServer, createHandlerOptions) {
|
|
11
|
+
var _a;
|
|
12
|
+
if (((_a = fCtx.event) === null || _a === void 0 ? void 0 : _a.path) && apolloPathRegex && apolloPathRegex.test(fCtx.event.path)) {
|
|
13
|
+
fCtx.result = await ApolloFilter.processApolloRequest(fCtx.event, fCtx.context, apolloServer, createHandlerOptions);
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
static async processApolloRequest(event, context, apolloServer, createHandlerOptions) {
|
|
21
|
+
ratchet_common_1.Logger.silly('Processing event with apollo: %j', event);
|
|
22
|
+
let rval = null;
|
|
23
|
+
if (!ApolloFilter.CACHE_APOLLO_HANDLER) {
|
|
24
|
+
ApolloFilter.CACHE_APOLLO_HANDLER = apolloServer.createHandler(createHandlerOptions);
|
|
25
|
+
}
|
|
26
|
+
event.multiValueHeaders = event.multiValueHeaders || {};
|
|
27
|
+
Object.keys(event.headers).forEach((k) => {
|
|
28
|
+
event.multiValueHeaders[k] = [event.headers[k]];
|
|
29
|
+
});
|
|
30
|
+
event.httpMethod = event.httpMethod.toUpperCase();
|
|
31
|
+
if (event.isBase64Encoded && !!event.body) {
|
|
32
|
+
event.body = Buffer.from(event.body, 'base64').toString();
|
|
33
|
+
event.isBase64Encoded = false;
|
|
34
|
+
}
|
|
35
|
+
const apolloPromise = ApolloFilter.CACHE_APOLLO_HANDLER(event, context, null) || Promise.resolve(null);
|
|
36
|
+
const timeoutMS = context.getRemainingTimeInMillis() - 500;
|
|
37
|
+
let result = null;
|
|
38
|
+
if (timeoutMS) {
|
|
39
|
+
result = await ratchet_common_2.PromiseRatchet.timeout(apolloPromise, 'Apollo timed out after ' + timeoutMS + ' ms.', timeoutMS);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
ratchet_common_1.Logger.warn('No timeout set even after defaulting for Apollo');
|
|
43
|
+
result = await apolloPromise;
|
|
44
|
+
}
|
|
45
|
+
if (ratchet_common_3.TimeoutToken.isTimeoutToken(result)) {
|
|
46
|
+
result.writeToLog();
|
|
47
|
+
throw new request_timeout_error_1.RequestTimeoutError('Timed out');
|
|
48
|
+
}
|
|
49
|
+
rval = result;
|
|
50
|
+
if (ratchet_common_4.StringRatchet.trimToEmpty(rval === null || rval === void 0 ? void 0 : rval.body).startsWith('<!DOCTYPE html>')) {
|
|
51
|
+
ratchet_common_1.Logger.info('Forcing content type to html');
|
|
52
|
+
rval.headers = rval.headers || {};
|
|
53
|
+
rval.headers['content-type'] = 'text/html';
|
|
54
|
+
}
|
|
55
|
+
return rval;
|
|
56
|
+
}
|
|
57
|
+
static addApolloFilterToList(filters, apolloPathRegex, apolloServer, createHandlerOptions) {
|
|
58
|
+
if (filters) {
|
|
59
|
+
filters.push((fCtx) => ApolloFilter.handlePathWithApollo(fCtx, apolloPathRegex, apolloServer, createHandlerOptions));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ApolloFilter = ApolloFilter;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuiltInAuthFilters = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const unauthorized_error_1 = require("../../http/error/unauthorized-error");
|
|
6
|
+
const misconfigured_error_1 = require("../../http/error/misconfigured-error");
|
|
7
|
+
const forbidden_error_1 = require("../../http/error/forbidden-error");
|
|
8
|
+
const event_util_1 = require("../../http/event-util");
|
|
9
|
+
class BuiltInAuthFilters {
|
|
10
|
+
static async requireAllRolesInCommonJwt(fCtx, requiredRoleAllOf) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
if (!requiredRoleAllOf || requiredRoleAllOf.length === 0) {
|
|
13
|
+
throw new misconfigured_error_1.MisconfiguredError('You must require at least 1 role');
|
|
14
|
+
}
|
|
15
|
+
if (!((_b = (_a = fCtx.event) === null || _a === void 0 ? void 0 : _a.authorization) === null || _b === void 0 ? void 0 : _b.auth)) {
|
|
16
|
+
throw new unauthorized_error_1.UnauthorizedError('May not proceed, not authenticated');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const asJwt = fCtx.event.authorization.auth;
|
|
20
|
+
if (!asJwt.roles || asJwt.roles.length === 0) {
|
|
21
|
+
throw new unauthorized_error_1.UnauthorizedError('Required role not found');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
requiredRoleAllOf.forEach((r) => {
|
|
25
|
+
if (!asJwt.roles.includes(r)) {
|
|
26
|
+
throw new unauthorized_error_1.UnauthorizedError('Required role not found');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
static async requireAnyRoleInCommonJwt(fCtx, requiredRoleOneOf) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
if (!requiredRoleOneOf || requiredRoleOneOf.length === 0) {
|
|
36
|
+
throw new misconfigured_error_1.MisconfiguredError('You must require at least 1 role');
|
|
37
|
+
}
|
|
38
|
+
if (!((_b = (_a = fCtx.event) === null || _a === void 0 ? void 0 : _a.authorization) === null || _b === void 0 ? void 0 : _b.auth)) {
|
|
39
|
+
throw new unauthorized_error_1.UnauthorizedError('May not proceed, not authenticated');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const asJwt = fCtx.event.authorization.auth;
|
|
43
|
+
if (!asJwt.roles || asJwt.roles.length === 0) {
|
|
44
|
+
throw new unauthorized_error_1.UnauthorizedError('Required role not found');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
let found = false;
|
|
48
|
+
requiredRoleOneOf.forEach((r) => {
|
|
49
|
+
if (!found && asJwt.roles.includes(r)) {
|
|
50
|
+
found = true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (!found) {
|
|
54
|
+
throw new unauthorized_error_1.UnauthorizedError('Required role not found');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
static async parseAuthorizationHeader(fCtx, webTokenManipulators) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (!(fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) || !webTokenManipulators || (Array.isArray(webTokenManipulators) && !webTokenManipulators.length)) {
|
|
63
|
+
throw new misconfigured_error_1.MisconfiguredError('Cannot continue - missing event or encryption');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const tokenString = event_util_1.EventUtil.extractBearerTokenFromEvent(fCtx === null || fCtx === void 0 ? void 0 : fCtx.event);
|
|
67
|
+
if (!Array.isArray(webTokenManipulators)) {
|
|
68
|
+
webTokenManipulators = [webTokenManipulators];
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < webTokenManipulators.length && !((_b = (_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _a === void 0 ? void 0 : _a.authorization) === null || _b === void 0 ? void 0 : _b.auth); i++) {
|
|
71
|
+
const manipulator = webTokenManipulators[i];
|
|
72
|
+
try {
|
|
73
|
+
const token = await manipulator.extractTokenFromAuthorizationHeader(tokenString);
|
|
74
|
+
fCtx.event.authorization = {
|
|
75
|
+
raw: tokenString,
|
|
76
|
+
auth: token,
|
|
77
|
+
error: null,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
fCtx.event.authorization = {
|
|
82
|
+
raw: tokenString,
|
|
83
|
+
auth: null,
|
|
84
|
+
error: err['message'],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
static async applyOpenApiAuthorization(fCtx) {
|
|
92
|
+
var _a, _b, _c, _d, _e;
|
|
93
|
+
if (ratchet_common_1.StringRatchet.trimToNull((_b = (_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.routeAndParse) === null || _a === void 0 ? void 0 : _a.mapping) === null || _b === void 0 ? void 0 : _b.authorizerName)) {
|
|
94
|
+
const authorizer = (_c = fCtx === null || fCtx === void 0 ? void 0 : fCtx.authenticators) === null || _c === void 0 ? void 0 : _c.get(fCtx.routeAndParse.mapping.authorizerName);
|
|
95
|
+
if (authorizer) {
|
|
96
|
+
if ((_e = (_d = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _d === void 0 ? void 0 : _d.authorization) === null || _e === void 0 ? void 0 : _e.auth) {
|
|
97
|
+
const allowed = await authorizer(fCtx.event.authorization, fCtx.event, fCtx.routeAndParse.mapping);
|
|
98
|
+
if (!allowed) {
|
|
99
|
+
throw new forbidden_error_1.ForbiddenError('You lack privileges to see this endpoint');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw new unauthorized_error_1.UnauthorizedError('You need to supply credentials for this endpoint');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw new misconfigured_error_1.MisconfiguredError().withFormattedErrorMessage('Authorizer %s requested but not found', fCtx.routeAndParse.mapping.authorizerName);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.BuiltInAuthFilters = BuiltInAuthFilters;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuiltInAuthorizers = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
class BuiltInAuthorizers {
|
|
6
|
+
static async simpleNoAuthenticationLogAccess(authorizationContext, evt) {
|
|
7
|
+
ratchet_common_1.Logger.debug('Auth requested for %s : %j', evt.path, authorizationContext === null || authorizationContext === void 0 ? void 0 : authorizationContext.auth);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
static async simpleLoggedInAuth(authorizationContext, evt) {
|
|
11
|
+
const rval = !!(authorizationContext === null || authorizationContext === void 0 ? void 0 : authorizationContext.auth);
|
|
12
|
+
ratchet_common_1.Logger.silly('SimpleLoggedInAuth returning %s for %s', rval, evt.path);
|
|
13
|
+
return rval;
|
|
14
|
+
}
|
|
15
|
+
static async simpleRoleRouteAuth(authorizationContext, event, route, requiredRoleOneOf = null, requiredRoleAllOf = null) {
|
|
16
|
+
let rval = true;
|
|
17
|
+
const token = authorizationContext === null || authorizationContext === void 0 ? void 0 : authorizationContext.auth;
|
|
18
|
+
if (token) {
|
|
19
|
+
if (requiredRoleOneOf) {
|
|
20
|
+
requiredRoleOneOf.forEach((r) => {
|
|
21
|
+
rval = rval || token.roles.indexOf(r) > -1;
|
|
22
|
+
});
|
|
23
|
+
if (!rval) {
|
|
24
|
+
ratchet_common_1.Logger.warn('Request to %s failed to find at least one of %j', route.path, requiredRoleOneOf);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (rval && requiredRoleAllOf) {
|
|
28
|
+
requiredRoleAllOf.forEach((r) => {
|
|
29
|
+
rval = rval && token.roles.indexOf(r) > -1;
|
|
30
|
+
});
|
|
31
|
+
if (!rval) {
|
|
32
|
+
ratchet_common_1.Logger.warn('Request to %s failed to find all of %j', route.path, requiredRoleAllOf);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
ratchet_common_1.Logger.warn('Cannot authenticate - no parsed auth found');
|
|
38
|
+
rval = false;
|
|
39
|
+
}
|
|
40
|
+
return rval;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.BuiltInAuthorizers = BuiltInAuthorizers;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuiltInFilters = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_common_2 = require("@bitblit/ratchet-common");
|
|
6
|
+
const ratchet_common_3 = require("@bitblit/ratchet-common");
|
|
7
|
+
const event_util_1 = require("../../http/event-util");
|
|
8
|
+
const bad_request_error_1 = require("../../http/error/bad-request-error");
|
|
9
|
+
const response_util_1 = require("../../http/response-util");
|
|
10
|
+
const epsilon_http_error_1 = require("../../http/error/epsilon-http-error");
|
|
11
|
+
const misconfigured_error_1 = require("../../http/error/misconfigured-error");
|
|
12
|
+
class BuiltInFilters {
|
|
13
|
+
static async combineFilters(fCtx, filters) {
|
|
14
|
+
let cont = true;
|
|
15
|
+
if (filters && filters.length > 0) {
|
|
16
|
+
for (let i = 0; i < filters.length && cont; i++) {
|
|
17
|
+
cont = await filters[i](fCtx);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return cont;
|
|
21
|
+
}
|
|
22
|
+
static async applyGzipIfPossible(fCtx) {
|
|
23
|
+
var _a;
|
|
24
|
+
if (((_a = fCtx.event) === null || _a === void 0 ? void 0 : _a.headers) && fCtx.result) {
|
|
25
|
+
const encodingHeader = fCtx.event && fCtx.event.headers ? ratchet_common_3.MapRatchet.extractValueFromMapIgnoreCase(fCtx.event.headers, 'accept-encoding') : null;
|
|
26
|
+
fCtx.result = await response_util_1.ResponseUtil.applyGzipIfPossible(encodingHeader, fCtx.result);
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
static async addConstantHeaders(fCtx, headers) {
|
|
31
|
+
if (headers && fCtx.result) {
|
|
32
|
+
fCtx.result.headers = Object.assign({}, headers, fCtx.result.headers);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
ratchet_common_1.Logger.warn('Could not add headers - either result or headers were missing');
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
static async addAWSRequestIdHeader(fCtx, headerName = 'X-REQUEST-ID') {
|
|
40
|
+
var _a;
|
|
41
|
+
if (fCtx.result && ratchet_common_2.StringRatchet.trimToNull(headerName) && headerName.startsWith('X-')) {
|
|
42
|
+
fCtx.result.headers = fCtx.result.headers || {};
|
|
43
|
+
fCtx.result.headers[headerName] = ((_a = fCtx.context) === null || _a === void 0 ? void 0 : _a.awsRequestId) || 'Request-Id-Missing';
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ratchet_common_1.Logger.warn('Could not add request id header - either result or context were missing or name was invalid');
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
static async addAllowEverythingCORSHeaders(fCtx) {
|
|
51
|
+
return BuiltInFilters.addConstantHeaders(fCtx, {
|
|
52
|
+
'Access-Control-Allow-Origin': '*',
|
|
53
|
+
'Access-Control-Allow-Methods': '*',
|
|
54
|
+
'Access-Control-Allow-Headers': '*',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static async addAllowReflectionCORSHeaders(fCtx) {
|
|
58
|
+
return BuiltInFilters.addConstantHeaders(fCtx, {
|
|
59
|
+
'Access-Control-Allow-Origin': ratchet_common_3.MapRatchet.caseInsensitiveAccess(fCtx.event.headers, 'Origin') || '*',
|
|
60
|
+
'Access-Control-Allow-Methods': ratchet_common_3.MapRatchet.caseInsensitiveAccess(fCtx.event.headers, 'Access-Control-Request-Method') || '*',
|
|
61
|
+
'Access-Control-Allow-Headers': ratchet_common_3.MapRatchet.caseInsensitiveAccess(fCtx.event.headers, 'Access-Control-Request-Headers') || '*',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
static async uriDecodeQueryParams(fCtx) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
if ((_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _a === void 0 ? void 0 : _a.queryStringParameters) {
|
|
67
|
+
Object.keys(fCtx.event.queryStringParameters).forEach((k) => {
|
|
68
|
+
const val = fCtx.event.queryStringParameters[k];
|
|
69
|
+
if (val) {
|
|
70
|
+
fCtx.event.queryStringParameters[k] = decodeURIComponent(val);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if ((_b = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _b === void 0 ? void 0 : _b.multiValueQueryStringParameters) {
|
|
75
|
+
Object.keys(fCtx.event.multiValueQueryStringParameters).forEach((k) => {
|
|
76
|
+
const val = fCtx.event.multiValueQueryStringParameters[k];
|
|
77
|
+
if (val && val.length) {
|
|
78
|
+
const cleaned = val.map((v) => decodeURIComponent(v));
|
|
79
|
+
fCtx.event.multiValueQueryStringParameters[k] = cleaned;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
static async fixStillEncodedQueryParams(fCtx) {
|
|
86
|
+
event_util_1.EventUtil.fixStillEncodedQueryParams(fCtx.event);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
static async disallowStringNullAsPathParameter(fCtx) {
|
|
90
|
+
var _a;
|
|
91
|
+
if ((_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _a === void 0 ? void 0 : _a.pathParameters) {
|
|
92
|
+
Object.keys(fCtx.event.pathParameters).forEach((k) => {
|
|
93
|
+
if ('null' === ratchet_common_2.StringRatchet.trimToEmpty(fCtx.event.pathParameters[k]).toLowerCase()) {
|
|
94
|
+
throw new bad_request_error_1.BadRequestError().withFormattedErrorMessage('Path parameter %s was string -null-', k);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
static async disallowStringNullAsQueryStringParameter(fCtx) {
|
|
101
|
+
var _a;
|
|
102
|
+
if ((_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _a === void 0 ? void 0 : _a.queryStringParameters) {
|
|
103
|
+
Object.keys(fCtx.event.queryStringParameters).forEach((k) => {
|
|
104
|
+
if ('null' === ratchet_common_2.StringRatchet.trimToEmpty(fCtx.event.queryStringParameters[k]).toLowerCase()) {
|
|
105
|
+
throw new bad_request_error_1.BadRequestError().withFormattedErrorMessage('Query parameter %s was string -null-', k);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
static async ensureEventMaps(fCtx) {
|
|
112
|
+
fCtx.event.queryStringParameters = fCtx.event.queryStringParameters || {};
|
|
113
|
+
fCtx.event.headers = fCtx.event.headers || {};
|
|
114
|
+
fCtx.event.pathParameters = fCtx.event.pathParameters || {};
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
static async parseJsonBodyToObject(fCtx) {
|
|
118
|
+
var _a;
|
|
119
|
+
if ((_a = fCtx.event) === null || _a === void 0 ? void 0 : _a.body) {
|
|
120
|
+
try {
|
|
121
|
+
fCtx.event.parsedBody = event_util_1.EventUtil.jsonBodyToObject(fCtx.event);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
throw new epsilon_http_error_1.EpsilonHttpError('Supplied body was not parsable as valid JSON').withHttpStatusCode(400);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
static async checkMaximumLambdaBodySize(fCtx) {
|
|
130
|
+
var _a;
|
|
131
|
+
if (((_a = fCtx.result) === null || _a === void 0 ? void 0 : _a.body) && fCtx.result.body.length > BuiltInFilters.MAXIMUM_LAMBDA_BODY_SIZE_BYTES) {
|
|
132
|
+
const delta = fCtx.result.body.length - BuiltInFilters.MAXIMUM_LAMBDA_BODY_SIZE_BYTES;
|
|
133
|
+
throw new epsilon_http_error_1.EpsilonHttpError('Response size is ' + fCtx.result.body.length + ' bytes, which is ' + delta + ' bytes too large for this handler').withHttpStatusCode(500);
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
static async validateInboundBody(fCtx) {
|
|
138
|
+
var _a;
|
|
139
|
+
if (((_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _a === void 0 ? void 0 : _a.parsedBody) && fCtx.routeAndParse) {
|
|
140
|
+
if (fCtx.routeAndParse.mapping.validation) {
|
|
141
|
+
if (!fCtx.modelValidator) {
|
|
142
|
+
throw new misconfigured_error_1.MisconfiguredError('Requested body validation but supplied no validator');
|
|
143
|
+
}
|
|
144
|
+
const errors = fCtx.modelValidator.validate(fCtx.routeAndParse.mapping.validation.modelName, fCtx.event.parsedBody, fCtx.routeAndParse.mapping.validation.emptyAllowed, fCtx.routeAndParse.mapping.validation.extraPropertiesAllowed);
|
|
145
|
+
if (errors.length > 0) {
|
|
146
|
+
ratchet_common_1.Logger.info('Found errors while validating %s object %j', fCtx.routeAndParse.mapping.validation.modelName, errors);
|
|
147
|
+
const newError = new bad_request_error_1.BadRequestError(...errors);
|
|
148
|
+
throw newError;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
ratchet_common_1.Logger.debug('No validation since no route specified or no parsed body');
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
static async validateInboundQueryParams(fCtx) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
static async validateInboundPathParams(fCtx) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
static async validateOutboundResponse(fCtx) {
|
|
164
|
+
if (fCtx === null || fCtx === void 0 ? void 0 : fCtx.rawResult) {
|
|
165
|
+
if (fCtx.routeAndParse.mapping.outboundValidation) {
|
|
166
|
+
ratchet_common_1.Logger.debug('Applying outbound check to %j', fCtx.rawResult);
|
|
167
|
+
const errors = fCtx.modelValidator.validate(fCtx.routeAndParse.mapping.outboundValidation.modelName, fCtx.rawResult, fCtx.routeAndParse.mapping.outboundValidation.emptyAllowed, fCtx.routeAndParse.mapping.outboundValidation.extraPropertiesAllowed);
|
|
168
|
+
if (errors.length > 0) {
|
|
169
|
+
ratchet_common_1.Logger.error('Found outbound errors while validating %s object %j', fCtx.routeAndParse.mapping.outboundValidation.modelName, errors);
|
|
170
|
+
errors.unshift('Server sent object invalid according to spec');
|
|
171
|
+
throw new epsilon_http_error_1.EpsilonHttpError().withErrors(errors).withHttpStatusCode(500).withDetails(fCtx.rawResult);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
ratchet_common_1.Logger.debug('Applied no outbound validation because none set');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
ratchet_common_1.Logger.debug('No validation since no outbound body or disabled');
|
|
180
|
+
}
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
static async autoRespondToOptionsRequestWithCors(fCtx) {
|
|
184
|
+
var _a;
|
|
185
|
+
if (ratchet_common_2.StringRatchet.trimToEmpty((_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.event) === null || _a === void 0 ? void 0 : _a.httpMethod).toLowerCase() === 'options') {
|
|
186
|
+
fCtx.result = {
|
|
187
|
+
statusCode: 200,
|
|
188
|
+
body: '{"cors":true, "m":2}',
|
|
189
|
+
};
|
|
190
|
+
await BuiltInFilters.addAllowReflectionCORSHeaders(fCtx);
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
static async autoRespond(fCtx, inBody) {
|
|
198
|
+
const body = inBody || {
|
|
199
|
+
message: 'Not Implemented',
|
|
200
|
+
};
|
|
201
|
+
fCtx.result = {
|
|
202
|
+
statusCode: 200,
|
|
203
|
+
body: JSON.stringify(body),
|
|
204
|
+
};
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
static async secureOutboundServerErrorForProduction(fCtx, errorMessage, errCode) {
|
|
208
|
+
var _a;
|
|
209
|
+
if ((_a = fCtx === null || fCtx === void 0 ? void 0 : fCtx.result) === null || _a === void 0 ? void 0 : _a.statusCode) {
|
|
210
|
+
if (errCode === null || fCtx.result.statusCode === errCode) {
|
|
211
|
+
ratchet_common_1.Logger.warn('Securing outbound error info (was : %j)', fCtx.result.body);
|
|
212
|
+
fCtx.rawResult = new epsilon_http_error_1.EpsilonHttpError(errorMessage).withHttpStatusCode(fCtx.result.statusCode);
|
|
213
|
+
const oldResult = fCtx.result;
|
|
214
|
+
fCtx.result = response_util_1.ResponseUtil.errorResponse(fCtx.rawResult);
|
|
215
|
+
fCtx.result.headers = Object.assign({}, oldResult.headers || {}, fCtx.result.headers || {});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.BuiltInFilters = BuiltInFilters;
|
|
222
|
+
BuiltInFilters.MAXIMUM_LAMBDA_BODY_SIZE_BYTES = 1024 * 1024 * 5 - 1024 * 100;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuiltInHandlers = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_common_2 = require("@bitblit/ratchet-common");
|
|
6
|
+
const ratchet_common_3 = require("@bitblit/ratchet-common");
|
|
7
|
+
const bad_request_error_1 = require("../../http/error/bad-request-error");
|
|
8
|
+
const epsilon_http_error_1 = require("../../http/error/epsilon-http-error");
|
|
9
|
+
const unauthorized_error_1 = require("../../http/error/unauthorized-error");
|
|
10
|
+
const not_found_error_1 = require("../../http/error/not-found-error");
|
|
11
|
+
const forbidden_error_1 = require("../../http/error/forbidden-error");
|
|
12
|
+
const not_implemented_1 = require("../../http/error/not-implemented");
|
|
13
|
+
const misconfigured_error_1 = require("../../http/error/misconfigured-error");
|
|
14
|
+
class BuiltInHandlers {
|
|
15
|
+
static async expectedHandledByFilter(evt, flag) {
|
|
16
|
+
throw new misconfigured_error_1.MisconfiguredError().withFormattedErrorMessage('Should not happen - it was expected that route %s would be handled by a filter', evt.path);
|
|
17
|
+
}
|
|
18
|
+
static async handleNotImplemented(evt, flag) {
|
|
19
|
+
ratchet_common_2.Logger.info('A request was made to %s with body %j - not yet implemented', evt.path, evt.body);
|
|
20
|
+
const rval = {
|
|
21
|
+
time: new Date().toLocaleString(),
|
|
22
|
+
path: evt.path,
|
|
23
|
+
message: 'NOT IMPLEMENTED YET',
|
|
24
|
+
};
|
|
25
|
+
return rval;
|
|
26
|
+
}
|
|
27
|
+
static async sample(evt, flag, context) {
|
|
28
|
+
const rval = {
|
|
29
|
+
time: new Date().toLocaleString(),
|
|
30
|
+
evt: evt,
|
|
31
|
+
pad: ratchet_common_1.StringRatchet.createRandomHexString(2000),
|
|
32
|
+
flag: flag,
|
|
33
|
+
};
|
|
34
|
+
if (context) {
|
|
35
|
+
rval['context'] = context;
|
|
36
|
+
}
|
|
37
|
+
const errNumber = ratchet_common_3.NumberRatchet.safeNumber(evt.queryStringParameters['error']);
|
|
38
|
+
if (errNumber) {
|
|
39
|
+
switch (errNumber) {
|
|
40
|
+
case -1:
|
|
41
|
+
throw new Error('Test random failure');
|
|
42
|
+
case 400:
|
|
43
|
+
throw new bad_request_error_1.BadRequestError('Bad request error');
|
|
44
|
+
case 401:
|
|
45
|
+
throw new unauthorized_error_1.UnauthorizedError('Unauthorized error');
|
|
46
|
+
case 403:
|
|
47
|
+
throw new forbidden_error_1.ForbiddenError('Forbidden error');
|
|
48
|
+
case 404:
|
|
49
|
+
throw new not_found_error_1.NotFoundError('Not Found error');
|
|
50
|
+
case 501:
|
|
51
|
+
throw new not_implemented_1.NotImplemented('Not Implemented');
|
|
52
|
+
default:
|
|
53
|
+
throw new epsilon_http_error_1.EpsilonHttpError()
|
|
54
|
+
.withFormattedErrorMessage('Default error - %s', errNumber)
|
|
55
|
+
.withHttpStatusCode(500)
|
|
56
|
+
.withDetails({ src: errNumber })
|
|
57
|
+
.withEndUserErrors(['msg1', 'msg2']);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
let test = ratchet_common_1.StringRatchet.trimToNull(evt.queryStringParameters['test']);
|
|
61
|
+
if (test) {
|
|
62
|
+
test = test.toLowerCase();
|
|
63
|
+
if (test === 'null') {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return rval;
|
|
68
|
+
}
|
|
69
|
+
static async defaultErrorProcessor(event, err, cfg) {
|
|
70
|
+
ratchet_common_2.Logger.warn('Unhandled error (in promise catch) : %s \nStack was: %s\nEvt was: %j\nConfig was: %j', err.message, err.stack, event, cfg);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.BuiltInHandlers = BuiltInHandlers;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevelManipulationFilter = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
class LogLevelManipulationFilter {
|
|
6
|
+
static async setLogLevelForTransaction(fCtx) {
|
|
7
|
+
LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE = ratchet_common_1.Logger.getLevel();
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
static async clearLogLevelForTransaction(fCtx) {
|
|
11
|
+
if (LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE) {
|
|
12
|
+
ratchet_common_1.Logger.setLevel(LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE);
|
|
13
|
+
LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE = null;
|
|
14
|
+
ratchet_common_1.Logger.updateTracePrefix(null);
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.LogLevelManipulationFilter = LogLevelManipulationFilter;
|
|
20
|
+
LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE = null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunHandlerAsFilter = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_common_2 = require("@bitblit/ratchet-common");
|
|
6
|
+
const ratchet_common_3 = require("@bitblit/ratchet-common");
|
|
7
|
+
const request_timeout_error_1 = require("../../http/error/request-timeout-error");
|
|
8
|
+
const response_util_1 = require("../../http/response-util");
|
|
9
|
+
const not_found_error_1 = require("../../http/error/not-found-error");
|
|
10
|
+
const null_returned_object_handling_1 = require("../../config/http/null-returned-object-handling");
|
|
11
|
+
const epsilon_http_error_1 = require("../../http/error/epsilon-http-error");
|
|
12
|
+
class RunHandlerAsFilter {
|
|
13
|
+
static async runHandler(fCtx, rm) {
|
|
14
|
+
const handler = RunHandlerAsFilter.findHandler(rm, fCtx.event, fCtx.context);
|
|
15
|
+
ratchet_common_1.Logger.debug('Processing event with epsilon: %j', fCtx.event);
|
|
16
|
+
let tmp = await handler;
|
|
17
|
+
if (ratchet_common_3.TimeoutToken.isTimeoutToken(tmp)) {
|
|
18
|
+
tmp.writeToLog();
|
|
19
|
+
throw new request_timeout_error_1.RequestTimeoutError('Timed out');
|
|
20
|
+
}
|
|
21
|
+
ratchet_common_1.Logger.debug('Initial return value : %j', tmp);
|
|
22
|
+
tmp = RunHandlerAsFilter.applyNullReturnedObjectHandling(tmp, rm.mapping.metaProcessingConfig.nullReturnedObjectHandling);
|
|
23
|
+
fCtx.rawResult = tmp;
|
|
24
|
+
fCtx.result = response_util_1.ResponseUtil.coerceToProxyResult(tmp);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
static applyNullReturnedObjectHandling(result, handling) {
|
|
28
|
+
let rval = result;
|
|
29
|
+
if (result === null || result === undefined) {
|
|
30
|
+
if (handling === null_returned_object_handling_1.NullReturnedObjectHandling.Error) {
|
|
31
|
+
ratchet_common_1.Logger.error('Null object returned and Error specified, throwing 500');
|
|
32
|
+
throw new epsilon_http_error_1.EpsilonHttpError('Null object').withHttpStatusCode(500);
|
|
33
|
+
}
|
|
34
|
+
else if (handling === null_returned_object_handling_1.NullReturnedObjectHandling.Return404NotFoundResponse) {
|
|
35
|
+
throw new not_found_error_1.NotFoundError('Resource not found');
|
|
36
|
+
}
|
|
37
|
+
else if (handling === null_returned_object_handling_1.NullReturnedObjectHandling.ConvertToEmptyString) {
|
|
38
|
+
ratchet_common_1.Logger.warn('Null object returned from handler and convert not specified, converting to empty string');
|
|
39
|
+
rval = '';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new epsilon_http_error_1.EpsilonHttpError('Cant happen - failed enum check').withHttpStatusCode(500);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return rval;
|
|
46
|
+
}
|
|
47
|
+
static async findHandler(rm, event, context, add404OnMissing = true) {
|
|
48
|
+
let rval = null;
|
|
49
|
+
if (rm) {
|
|
50
|
+
event.pathParameters = Object.assign({}, event.pathParameters, rm.parsed);
|
|
51
|
+
rval = ratchet_common_2.PromiseRatchet.timeout(rm.mapping.function(event, context), 'Timed out after ' + rm.mapping.metaProcessingConfig.timeoutMS + ' ms. Request was ' + JSON.stringify(event), rm.mapping.metaProcessingConfig.timeoutMS);
|
|
52
|
+
}
|
|
53
|
+
else if (add404OnMissing) {
|
|
54
|
+
throw new not_found_error_1.NotFoundError('No such endpoint');
|
|
55
|
+
}
|
|
56
|
+
return rval;
|
|
57
|
+
}
|
|
58
|
+
static addRunHandlerAsFilterToList(filters, rm) {
|
|
59
|
+
if (filters) {
|
|
60
|
+
filters.push((fCtx) => RunHandlerAsFilter.runHandler(fCtx, rm));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.RunHandlerAsFilter = RunHandlerAsFilter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var _a;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const run_background_process_from_command_line_1 = require("../run-background-process-from-command-line");
|
|
6
|
+
const ratchet_node_only_1 = require("@bitblit/ratchet-node-only");
|
|
7
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
8
|
+
if (((_a = process === null || process === void 0 ? void 0 : process.argv) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
9
|
+
ratchet_node_only_1.CliRatchet.isCalledFromCLI([
|
|
10
|
+
'epsilon-run-background-process-from-command-line-dry-run.js',
|
|
11
|
+
'epsilon-run-background-process-from-command-line-dry-run',
|
|
12
|
+
])) {
|
|
13
|
+
run_background_process_from_command_line_1.RunBackgroundProcessFromCommandLine.processBackgroundCliRequest(null, true)
|
|
14
|
+
.then((out) => {
|
|
15
|
+
ratchet_common_1.Logger.info('Result : %s', out);
|
|
16
|
+
})
|
|
17
|
+
.catch((err) => ratchet_common_1.Logger.error('Failed : %s', err));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
}
|