@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,69 @@
|
|
|
1
|
+
import { StringRatchet } from '@bitblit/ratchet-common';
|
|
2
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
3
|
+
import { NumberRatchet } from '@bitblit/ratchet-common';
|
|
4
|
+
import { BadRequestError } from '../../http/error/bad-request-error';
|
|
5
|
+
import { EpsilonHttpError } from '../../http/error/epsilon-http-error';
|
|
6
|
+
import { UnauthorizedError } from '../../http/error/unauthorized-error';
|
|
7
|
+
import { NotFoundError } from '../../http/error/not-found-error';
|
|
8
|
+
import { ForbiddenError } from '../../http/error/forbidden-error';
|
|
9
|
+
import { NotImplemented } from '../../http/error/not-implemented';
|
|
10
|
+
import { MisconfiguredError } from '../../http/error/misconfigured-error';
|
|
11
|
+
export class BuiltInHandlers {
|
|
12
|
+
static async expectedHandledByFilter(evt, flag) {
|
|
13
|
+
throw new MisconfiguredError().withFormattedErrorMessage('Should not happen - it was expected that route %s would be handled by a filter', evt.path);
|
|
14
|
+
}
|
|
15
|
+
static async handleNotImplemented(evt, flag) {
|
|
16
|
+
Logger.info('A request was made to %s with body %j - not yet implemented', evt.path, evt.body);
|
|
17
|
+
const rval = {
|
|
18
|
+
time: new Date().toLocaleString(),
|
|
19
|
+
path: evt.path,
|
|
20
|
+
message: 'NOT IMPLEMENTED YET',
|
|
21
|
+
};
|
|
22
|
+
return rval;
|
|
23
|
+
}
|
|
24
|
+
static async sample(evt, flag, context) {
|
|
25
|
+
const rval = {
|
|
26
|
+
time: new Date().toLocaleString(),
|
|
27
|
+
evt: evt,
|
|
28
|
+
pad: StringRatchet.createRandomHexString(2000),
|
|
29
|
+
flag: flag,
|
|
30
|
+
};
|
|
31
|
+
if (context) {
|
|
32
|
+
rval['context'] = context;
|
|
33
|
+
}
|
|
34
|
+
const errNumber = NumberRatchet.safeNumber(evt.queryStringParameters['error']);
|
|
35
|
+
if (errNumber) {
|
|
36
|
+
switch (errNumber) {
|
|
37
|
+
case -1:
|
|
38
|
+
throw new Error('Test random failure');
|
|
39
|
+
case 400:
|
|
40
|
+
throw new BadRequestError('Bad request error');
|
|
41
|
+
case 401:
|
|
42
|
+
throw new UnauthorizedError('Unauthorized error');
|
|
43
|
+
case 403:
|
|
44
|
+
throw new ForbiddenError('Forbidden error');
|
|
45
|
+
case 404:
|
|
46
|
+
throw new NotFoundError('Not Found error');
|
|
47
|
+
case 501:
|
|
48
|
+
throw new NotImplemented('Not Implemented');
|
|
49
|
+
default:
|
|
50
|
+
throw new EpsilonHttpError()
|
|
51
|
+
.withFormattedErrorMessage('Default error - %s', errNumber)
|
|
52
|
+
.withHttpStatusCode(500)
|
|
53
|
+
.withDetails({ src: errNumber })
|
|
54
|
+
.withEndUserErrors(['msg1', 'msg2']);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let test = StringRatchet.trimToNull(evt.queryStringParameters['test']);
|
|
58
|
+
if (test) {
|
|
59
|
+
test = test.toLowerCase();
|
|
60
|
+
if (test === 'null') {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return rval;
|
|
65
|
+
}
|
|
66
|
+
static async defaultErrorProcessor(event, err, cfg) {
|
|
67
|
+
Logger.warn('Unhandled error (in promise catch) : %s \nStack was: %s\nEvt was: %j\nConfig was: %j', err.message, err.stack, event, cfg);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
export class LogLevelManipulationFilter {
|
|
3
|
+
static async setLogLevelForTransaction(fCtx) {
|
|
4
|
+
LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE = Logger.getLevel();
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
static async clearLogLevelForTransaction(fCtx) {
|
|
8
|
+
if (LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE) {
|
|
9
|
+
Logger.setLevel(LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE);
|
|
10
|
+
LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE = null;
|
|
11
|
+
Logger.updateTracePrefix(null);
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
LogLevelManipulationFilter.LOG_LEVEL_BEFORE_CHANGE = null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
import { PromiseRatchet } from '@bitblit/ratchet-common';
|
|
3
|
+
import { TimeoutToken } from '@bitblit/ratchet-common';
|
|
4
|
+
import { RequestTimeoutError } from '../../http/error/request-timeout-error';
|
|
5
|
+
import { ResponseUtil } from '../../http/response-util';
|
|
6
|
+
import { NotFoundError } from '../../http/error/not-found-error';
|
|
7
|
+
import { NullReturnedObjectHandling } from '../../config/http/null-returned-object-handling';
|
|
8
|
+
import { EpsilonHttpError } from '../../http/error/epsilon-http-error';
|
|
9
|
+
export class RunHandlerAsFilter {
|
|
10
|
+
static async runHandler(fCtx, rm) {
|
|
11
|
+
const handler = RunHandlerAsFilter.findHandler(rm, fCtx.event, fCtx.context);
|
|
12
|
+
Logger.debug('Processing event with epsilon: %j', fCtx.event);
|
|
13
|
+
let tmp = await handler;
|
|
14
|
+
if (TimeoutToken.isTimeoutToken(tmp)) {
|
|
15
|
+
tmp.writeToLog();
|
|
16
|
+
throw new RequestTimeoutError('Timed out');
|
|
17
|
+
}
|
|
18
|
+
Logger.debug('Initial return value : %j', tmp);
|
|
19
|
+
tmp = RunHandlerAsFilter.applyNullReturnedObjectHandling(tmp, rm.mapping.metaProcessingConfig.nullReturnedObjectHandling);
|
|
20
|
+
fCtx.rawResult = tmp;
|
|
21
|
+
fCtx.result = ResponseUtil.coerceToProxyResult(tmp);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
static applyNullReturnedObjectHandling(result, handling) {
|
|
25
|
+
let rval = result;
|
|
26
|
+
if (result === null || result === undefined) {
|
|
27
|
+
if (handling === NullReturnedObjectHandling.Error) {
|
|
28
|
+
Logger.error('Null object returned and Error specified, throwing 500');
|
|
29
|
+
throw new EpsilonHttpError('Null object').withHttpStatusCode(500);
|
|
30
|
+
}
|
|
31
|
+
else if (handling === NullReturnedObjectHandling.Return404NotFoundResponse) {
|
|
32
|
+
throw new NotFoundError('Resource not found');
|
|
33
|
+
}
|
|
34
|
+
else if (handling === NullReturnedObjectHandling.ConvertToEmptyString) {
|
|
35
|
+
Logger.warn('Null object returned from handler and convert not specified, converting to empty string');
|
|
36
|
+
rval = '';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new EpsilonHttpError('Cant happen - failed enum check').withHttpStatusCode(500);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return rval;
|
|
43
|
+
}
|
|
44
|
+
static async findHandler(rm, event, context, add404OnMissing = true) {
|
|
45
|
+
let rval = null;
|
|
46
|
+
if (rm) {
|
|
47
|
+
event.pathParameters = Object.assign({}, event.pathParameters, rm.parsed);
|
|
48
|
+
rval = PromiseRatchet.timeout(rm.mapping.function(event, context), 'Timed out after ' + rm.mapping.metaProcessingConfig.timeoutMS + ' ms. Request was ' + JSON.stringify(event), rm.mapping.metaProcessingConfig.timeoutMS);
|
|
49
|
+
}
|
|
50
|
+
else if (add404OnMissing) {
|
|
51
|
+
throw new NotFoundError('No such endpoint');
|
|
52
|
+
}
|
|
53
|
+
return rval;
|
|
54
|
+
}
|
|
55
|
+
static addRunHandlerAsFilterToList(filters, rm) {
|
|
56
|
+
if (filters) {
|
|
57
|
+
filters.push((fCtx) => RunHandlerAsFilter.runHandler(fCtx, rm));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { RunBackgroundProcessFromCommandLine } from '../run-background-process-from-command-line';
|
|
3
|
+
import { CliRatchet } from '@bitblit/ratchet-node-only';
|
|
4
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
5
|
+
if (process?.argv?.length &&
|
|
6
|
+
CliRatchet.isCalledFromCLI([
|
|
7
|
+
'epsilon-run-background-process-from-command-line-dry-run.js',
|
|
8
|
+
'epsilon-run-background-process-from-command-line-dry-run',
|
|
9
|
+
])) {
|
|
10
|
+
RunBackgroundProcessFromCommandLine.processBackgroundCliRequest(null, true)
|
|
11
|
+
.then((out) => {
|
|
12
|
+
Logger.info('Result : %s', out);
|
|
13
|
+
})
|
|
14
|
+
.catch((err) => Logger.error('Failed : %s', err));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var NullReturnedObjectHandling;
|
|
2
|
+
(function (NullReturnedObjectHandling) {
|
|
3
|
+
NullReturnedObjectHandling["Error"] = "Error";
|
|
4
|
+
NullReturnedObjectHandling["ConvertToEmptyString"] = "ConvertToEmptyString";
|
|
5
|
+
NullReturnedObjectHandling["Return404NotFoundResponse"] = "Return404NotFoundResponse";
|
|
6
|
+
})(NullReturnedObjectHandling || (NullReturnedObjectHandling = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StringRatchet } from '@bitblit/ratchet-common';
|
|
2
|
+
export class EpsilonBuildProperties {
|
|
3
|
+
constructor() { }
|
|
4
|
+
static get buildVersion() {
|
|
5
|
+
return 'LOCAL-SNAPSHOT';
|
|
6
|
+
}
|
|
7
|
+
static get buildHash() {
|
|
8
|
+
return 'LOCAL-HASH';
|
|
9
|
+
}
|
|
10
|
+
static get buildBranch() {
|
|
11
|
+
return 'LOCAL-BRANCH';
|
|
12
|
+
}
|
|
13
|
+
static get buildTag() {
|
|
14
|
+
return 'LOCAL-TAG';
|
|
15
|
+
}
|
|
16
|
+
static get buildBranchOrTag() {
|
|
17
|
+
return StringRatchet.trimToNull(EpsilonBuildProperties.buildBranch)
|
|
18
|
+
? 'BRANCH:' + EpsilonBuildProperties.buildBranch
|
|
19
|
+
: 'TAG:' + EpsilonBuildProperties.buildTag;
|
|
20
|
+
}
|
|
21
|
+
static get buildTime() {
|
|
22
|
+
return 'LOCAL-TIME';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
export class EpsilonConstants {
|
|
3
|
+
static load(filePath, className) {
|
|
4
|
+
Logger.info('Searching for %s : %s : %s', filePath, className, __dirname);
|
|
5
|
+
let rval = null;
|
|
6
|
+
const val = require(filePath);
|
|
7
|
+
if (val) {
|
|
8
|
+
Logger.debug('Found %s - pulling object : %j : %s', filePath, Object.keys(val), className);
|
|
9
|
+
rval = val[className];
|
|
10
|
+
}
|
|
11
|
+
return rval;
|
|
12
|
+
}
|
|
13
|
+
static async findDynamicImportEpsilonGlobalHandlerProvider() {
|
|
14
|
+
const importPath = process.env[EpsilonConstants.EPSILON_FINDER_DYNAMIC_IMPORT_PATH_ENV_NAME] ||
|
|
15
|
+
EpsilonConstants.DEFAULT_EPSILON_FINDER_DYNAMIC_IMPORT_PATH;
|
|
16
|
+
const fnName = process.env[EpsilonConstants.EPSILON_FINDER_FUNCTION_NAME_ENV_NAME] || EpsilonConstants.DEFAULT_EPSILON_FINDER_FUNCTION_NAME;
|
|
17
|
+
Logger.debug('Using epsilon finder dynamic import path : %s / %s', importPath, fnName);
|
|
18
|
+
let provider = null;
|
|
19
|
+
try {
|
|
20
|
+
provider = this.load(importPath, fnName);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
Logger.error('Error loading provider : %s / %s : %s', importPath, fnName, err, err);
|
|
24
|
+
}
|
|
25
|
+
let rval = null;
|
|
26
|
+
if (provider) {
|
|
27
|
+
Logger.debug('Type2 is : %s', typeof provider);
|
|
28
|
+
Logger.info('Got3 : %s : %s', provider, typeof provider);
|
|
29
|
+
rval = provider();
|
|
30
|
+
Logger.info('Rval3 is %s', rval);
|
|
31
|
+
}
|
|
32
|
+
return rval;
|
|
33
|
+
}
|
|
34
|
+
constructor() { }
|
|
35
|
+
}
|
|
36
|
+
EpsilonConstants.EPSILON_FINDER_DYNAMIC_IMPORT_PATH_ENV_NAME = 'EPSILON_FINDER_DYNAMIC_IMPORT_PATH';
|
|
37
|
+
EpsilonConstants.EPSILON_FINDER_FUNCTION_NAME_ENV_NAME = 'EPSILON_FINDER_FUNCTION_NAME';
|
|
38
|
+
EpsilonConstants.DEFAULT_EPSILON_FINDER_DYNAMIC_IMPORT_PATH = 'epsilon-global-handler-provider.js';
|
|
39
|
+
EpsilonConstants.DEFAULT_EPSILON_FINDER_FUNCTION_NAME = 'findEpsilonGlobalHandler';
|
|
40
|
+
EpsilonConstants.AUTH_HEADER_PREFIX = 'Bearer ';
|
|
41
|
+
EpsilonConstants.AUTH_HEADER_NAME = 'Authorization';
|
|
42
|
+
EpsilonConstants.BACKGROUND_SQS_TYPE_FIELD = 'BACKGROUND_TYPE';
|
|
43
|
+
EpsilonConstants.BACKGROUND_SNS_START_MARKER = 'BACKGROUND_START_MARKER';
|
|
44
|
+
EpsilonConstants.BACKGROUND_SNS_IMMEDIATE_RUN_FLAG = 'BACKGROUND_IMMEDIATE_RUN_FLAG';
|
|
45
|
+
EpsilonConstants.INTER_API_SNS_EVENT = 'EPSILON_INTER_API_EVENT';
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
import { EventUtil } from './http/event-util';
|
|
3
|
+
import { TimeoutToken } from '@bitblit/ratchet-common';
|
|
4
|
+
import { PromiseRatchet } from '@bitblit/ratchet-common';
|
|
5
|
+
import { ResponseUtil } from './http/response-util';
|
|
6
|
+
import { EpsilonHttpError } from './http/error/epsilon-http-error';
|
|
7
|
+
import { RequestTimeoutError } from './http/error/request-timeout-error';
|
|
8
|
+
import { ErrorRatchet, LoggerLevelName, LoggerOutputFunction, LogMessageFormatType, } from '@bitblit/ratchet-common';
|
|
9
|
+
import { ContextUtil } from './util/context-util';
|
|
10
|
+
import { WebV2Handler } from './http/web-v2-handler';
|
|
11
|
+
import { InterApiEpsilonLambdaEventHandler } from './lambda-event-handler/inter-api-epsilon-lambda-event-handler';
|
|
12
|
+
import { GenericSnsEpsilonLambdaEventHandler } from './lambda-event-handler/generic-sns-epsilon-lambda-event-handler';
|
|
13
|
+
import { CronEpsilonLambdaEventHandler } from './lambda-event-handler/cron-epsilon-lambda-event-handler';
|
|
14
|
+
import { S3EpsilonLambdaEventHandler } from './lambda-event-handler/s3-epsilon-lambda-event-handler';
|
|
15
|
+
import { DynamoEpsilonLambdaEventHandler } from './lambda-event-handler/dynamo-epsilon-lambda-event-handler';
|
|
16
|
+
import { EpsilonLoggingExtensionProcessor } from './epsilon-logging-extension-processor';
|
|
17
|
+
export class EpsilonGlobalHandler {
|
|
18
|
+
static set globalInstanceProvider(input) {
|
|
19
|
+
EpsilonGlobalHandler.GLOBAL_INSTANCE_PROVIDER = input;
|
|
20
|
+
}
|
|
21
|
+
static get globalInstanceProvider() {
|
|
22
|
+
return EpsilonGlobalHandler.GLOBAL_INSTANCE_PROVIDER;
|
|
23
|
+
}
|
|
24
|
+
constructor(_epsilon) {
|
|
25
|
+
this._epsilon = _epsilon;
|
|
26
|
+
this.handlers = null;
|
|
27
|
+
if (!EpsilonGlobalHandler.LOGGER_CONFIGURED) {
|
|
28
|
+
EpsilonGlobalHandler.configureDefaultLogger();
|
|
29
|
+
Logger.info('EpsilonLoggingConfiguration:Default logger configured');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
Logger.info('EpsilonLoggingConfiguration:Skipping default logger config - already configured');
|
|
33
|
+
}
|
|
34
|
+
this.handlers = [
|
|
35
|
+
this._epsilon.webHandler,
|
|
36
|
+
new WebV2Handler(this._epsilon.webHandler),
|
|
37
|
+
this._epsilon.backgroundHandler,
|
|
38
|
+
new InterApiEpsilonLambdaEventHandler(this._epsilon),
|
|
39
|
+
new GenericSnsEpsilonLambdaEventHandler(this._epsilon),
|
|
40
|
+
new CronEpsilonLambdaEventHandler(this._epsilon),
|
|
41
|
+
new S3EpsilonLambdaEventHandler(this._epsilon),
|
|
42
|
+
new DynamoEpsilonLambdaEventHandler(this._epsilon),
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
static configureDefaultLogger(overrides) {
|
|
46
|
+
const output = overrides ? Object.assign({}, overrides) : {};
|
|
47
|
+
output.initialLevel = output.initialLevel ?? LoggerLevelName.info;
|
|
48
|
+
output.formatType = output.formatType ?? LogMessageFormatType.StructuredJson;
|
|
49
|
+
output.globalVars = output.globalVars ?? {};
|
|
50
|
+
output.outputFunction = output.outputFunction ?? LoggerOutputFunction.StdOut;
|
|
51
|
+
output.ringBufferSize = output.ringBufferSize ?? 0;
|
|
52
|
+
const src = output.preProcessors || [];
|
|
53
|
+
output.preProcessors = src.concat([new EpsilonLoggingExtensionProcessor()]);
|
|
54
|
+
const pre = Logger.getOptions();
|
|
55
|
+
Logger.changeDefaultOptions(output, true);
|
|
56
|
+
const post = Logger.getOptions();
|
|
57
|
+
EpsilonGlobalHandler.LOGGER_CONFIGURED = true;
|
|
58
|
+
Logger.info('EpsilonLoggingConfiguration: Updated');
|
|
59
|
+
Logger.dumpOptionsIntoLog();
|
|
60
|
+
}
|
|
61
|
+
get epsilon() {
|
|
62
|
+
return this._epsilon;
|
|
63
|
+
}
|
|
64
|
+
async processSingleBackgroundByParts(type, data, overrideTraceId, overrideTraceDepth) {
|
|
65
|
+
return this.processSingleBackgroundEntry(this._epsilon.backgroundManager.createEntry(type, data), overrideTraceId, overrideTraceDepth);
|
|
66
|
+
}
|
|
67
|
+
async processSingleBackgroundEntry(e, overrideTraceId, overrideTraceDepth) {
|
|
68
|
+
let rval = false;
|
|
69
|
+
if (e?.type) {
|
|
70
|
+
const internal = this._epsilon.backgroundManager.wrapEntryForInternal(e, overrideTraceId, overrideTraceDepth);
|
|
71
|
+
rval = await this._epsilon.backgroundHandler.processSingleBackgroundEntry(internal);
|
|
72
|
+
Logger.info('Direct processed request %j to %s', e, rval);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
Logger.error('Cannot process null/unnamed background entry');
|
|
76
|
+
}
|
|
77
|
+
return rval;
|
|
78
|
+
}
|
|
79
|
+
async lambdaHandler(event, context) {
|
|
80
|
+
let rval = null;
|
|
81
|
+
try {
|
|
82
|
+
if (this.epsilon.config.disableLastResortTimeout || !context || !context.getRemainingTimeInMillis()) {
|
|
83
|
+
rval = await this.innerLambdaHandler(event, context);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const tmp = await PromiseRatchet.timeout(this.innerLambdaHandler(event, context), 'EpsilonLastResortTimeout', context.getRemainingTimeInMillis() - 1000);
|
|
87
|
+
if (TimeoutToken.isTimeoutToken(tmp)) {
|
|
88
|
+
tmp.writeToLog();
|
|
89
|
+
rval = ResponseUtil.errorResponse(EpsilonHttpError.wrapError(new RequestTimeoutError('Timed out')));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
rval = tmp;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
ContextUtil.clearContext();
|
|
98
|
+
}
|
|
99
|
+
return rval;
|
|
100
|
+
}
|
|
101
|
+
async innerLambdaHandler(event, context) {
|
|
102
|
+
ContextUtil.initContext(this._epsilon, event, context, 'TBD');
|
|
103
|
+
let rval = null;
|
|
104
|
+
let errorHandler = EpsilonGlobalHandler.defaultProcessUncaughtError;
|
|
105
|
+
try {
|
|
106
|
+
if (!this._epsilon) {
|
|
107
|
+
Logger.error('Config not found, abandoning');
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const logLevel = EventUtil.calcLogLevelViaEventOrEnvParam(Logger.getLevel(), event, this._epsilon.config.loggerConfig);
|
|
111
|
+
Logger.setLevel(logLevel);
|
|
112
|
+
if (this._epsilon.config.loggerConfig &&
|
|
113
|
+
this._epsilon.config.loggerConfig.queryParamTracePrefixName &&
|
|
114
|
+
event.queryStringParameters &&
|
|
115
|
+
event.queryStringParameters[this._epsilon.config.loggerConfig.queryParamTracePrefixName]) {
|
|
116
|
+
Logger.info('Setting trace prefix to %s', event.queryStringParameters[this._epsilon.config.loggerConfig.queryParamTracePrefixName]);
|
|
117
|
+
Logger.updateTracePrefix(event.queryStringParameters[this._epsilon.config.loggerConfig.queryParamTracePrefixName]);
|
|
118
|
+
}
|
|
119
|
+
let found = false;
|
|
120
|
+
for (let i = 0; i < this.handlers.length && !found; i++) {
|
|
121
|
+
const handler = this.handlers[i];
|
|
122
|
+
if (handler.handlesEvent(event)) {
|
|
123
|
+
found = true;
|
|
124
|
+
errorHandler = handler.processUncaughtError || errorHandler;
|
|
125
|
+
const label = handler.extractLabel(event, context);
|
|
126
|
+
ContextUtil.setProcessLabel(label);
|
|
127
|
+
Logger.logByLevel(this._epsilon?.config?.loggerConfig?.epsilonStartEndMessageLogLevel || LoggerLevelName.info, 'EvtStart: %s', label);
|
|
128
|
+
rval = await handler.processEvent(event, context);
|
|
129
|
+
Logger.logByLevel(this._epsilon?.config?.loggerConfig?.epsilonStartEndMessageLogLevel || LoggerLevelName.info, 'EvtEnd: %s', label);
|
|
130
|
+
Logger.silly('EvtEnd:Value: %s Value: %j', label, rval);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
rval = await errorHandler(event, context, err);
|
|
136
|
+
}
|
|
137
|
+
return rval;
|
|
138
|
+
}
|
|
139
|
+
static async defaultProcessUncaughtError(event, context, err) {
|
|
140
|
+
Logger.error('Error slipped out to outer edge (Default). Logging and returning log : %s', err, err);
|
|
141
|
+
const rval = {
|
|
142
|
+
statusCode: 500,
|
|
143
|
+
body: JSON.stringify({ error: ErrorRatchet.safeStringifyErr(err) }),
|
|
144
|
+
isBase64Encoded: false,
|
|
145
|
+
};
|
|
146
|
+
return rval;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
EpsilonGlobalHandler.LOGGER_CONFIGURED = false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContextUtil } from './util/context-util';
|
|
2
|
+
export class EpsilonLoggingExtensionProcessor {
|
|
3
|
+
process(msg) {
|
|
4
|
+
msg.params = Object.assign({}, msg.params || {}, ContextUtil.fetchLogVariables());
|
|
5
|
+
msg.params['tester'] = Date.now();
|
|
6
|
+
msg.params['awsRequestId'] = ContextUtil.currentRequestId();
|
|
7
|
+
msg.params['traceId'] = ContextUtil.currentTraceId();
|
|
8
|
+
msg.params['traceDepth'] = ContextUtil.currentTraceDepth();
|
|
9
|
+
msg.params['procLabel'] = ContextUtil.currentProcessLabel();
|
|
10
|
+
return msg;
|
|
11
|
+
}
|
|
12
|
+
label() {
|
|
13
|
+
return 'EpsilonLoggingExtensionProcessor';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
import { LocalWebTokenManipulator } from './local-web-token-manipulator';
|
|
3
|
+
import { EpsilonConstants } from '../../epsilon-constants';
|
|
4
|
+
export class ApiGatewayAdapterAuthenticationHandler {
|
|
5
|
+
constructor(issuer, encryptionKeys) {
|
|
6
|
+
this.webTokenManipulator = new LocalWebTokenManipulator([encryptionKeys], issuer);
|
|
7
|
+
}
|
|
8
|
+
lambdaHandler(event, context, callback) {
|
|
9
|
+
Logger.info('Got event : %j', event);
|
|
10
|
+
const srcString = ApiGatewayAdapterAuthenticationHandler.extractTokenStringFromAuthorizerEvent(event);
|
|
11
|
+
if (srcString) {
|
|
12
|
+
const methodArn = event.methodArn;
|
|
13
|
+
this.webTokenManipulator
|
|
14
|
+
.parseAndValidateJWTStringAsync(srcString)
|
|
15
|
+
.then((parsed) => {
|
|
16
|
+
if (parsed) {
|
|
17
|
+
callback(null, this.createPolicy(methodArn, srcString, parsed));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
Logger.info('Invalid bearer token');
|
|
21
|
+
callback(new Error('Unauthorized'));
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
.catch((err) => {
|
|
25
|
+
Logger.error('Exception parsing token : %s', err);
|
|
26
|
+
callback(new Error('Unauthorized'));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
Logger.info('Token not supplied');
|
|
31
|
+
callback(new Error('Unauthorized'));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
createPolicy(methodArn, srcString, userOb) {
|
|
35
|
+
const tmp = methodArn.split(':');
|
|
36
|
+
const apiGatewayArnTmp = tmp[5].split('/');
|
|
37
|
+
const awsAccountId = tmp[4];
|
|
38
|
+
const region = tmp[3];
|
|
39
|
+
const stage = apiGatewayArnTmp[1];
|
|
40
|
+
const restApiId = apiGatewayArnTmp[0];
|
|
41
|
+
const response = {
|
|
42
|
+
principalId: 'user',
|
|
43
|
+
policyDocument: {
|
|
44
|
+
Version: '2012-10-17',
|
|
45
|
+
Statement: [
|
|
46
|
+
{
|
|
47
|
+
Action: 'execute-api:Invoke',
|
|
48
|
+
Effect: 'Allow',
|
|
49
|
+
Resource: ['arn:aws:execute-api:' + region + ':' + awsAccountId + ':' + restApiId + '/' + stage + '/*/*'],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
context: {
|
|
54
|
+
userJSON: JSON.stringify(userOb),
|
|
55
|
+
srcData: srcString,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
static extractTokenStringFromAuthorizerEvent(event) {
|
|
61
|
+
Logger.silly('Extracting token from event : %j', event);
|
|
62
|
+
let rval = null;
|
|
63
|
+
if (event && event.authorizationToken) {
|
|
64
|
+
const token = event.authorizationToken;
|
|
65
|
+
if (token && token.startsWith(EpsilonConstants.AUTH_HEADER_PREFIX)) {
|
|
66
|
+
rval = token.substring(EpsilonConstants.AUTH_HEADER_PREFIX.length);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return rval;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Logger, StringRatchet } from '@bitblit/ratchet-common';
|
|
2
|
+
import jwt from 'jsonwebtoken';
|
|
3
|
+
import jwks from 'jwks-rsa';
|
|
4
|
+
export class Auth0WebTokenManipulator {
|
|
5
|
+
constructor(clientId, jwksUri, issuer) {
|
|
6
|
+
this.clientId = clientId;
|
|
7
|
+
this.jwksUri = jwksUri;
|
|
8
|
+
this.issuer = issuer;
|
|
9
|
+
}
|
|
10
|
+
async extractTokenFromAuthorizationHeader(authHeader) {
|
|
11
|
+
let tokenString = StringRatchet.trimToEmpty(authHeader);
|
|
12
|
+
if (tokenString.toLowerCase().startsWith('bearer ')) {
|
|
13
|
+
tokenString = tokenString.substring(7);
|
|
14
|
+
}
|
|
15
|
+
const validated = tokenString ? await this.parseAndValidateAuth0Token(tokenString, false) : null;
|
|
16
|
+
return validated;
|
|
17
|
+
}
|
|
18
|
+
async parseAndValidateAuth0Token(auth0Token, allowExpired = false) {
|
|
19
|
+
Logger.debug('Validating Auth0 token : %s', StringRatchet.obscure(auth0Token, 4));
|
|
20
|
+
const fullToken = jwt.decode(auth0Token, { complete: true });
|
|
21
|
+
const kid = fullToken?.header?.kid;
|
|
22
|
+
const nowEpochSeconds = Math.floor(new Date().getTime() / 1000);
|
|
23
|
+
const pubKey = await this.fetchSigningKey(kid);
|
|
24
|
+
const validated = jwt.verify(auth0Token, pubKey, {
|
|
25
|
+
audience: this.clientId,
|
|
26
|
+
issuer: this.issuer,
|
|
27
|
+
ignoreExpiration: allowExpired,
|
|
28
|
+
clockTimestamp: nowEpochSeconds,
|
|
29
|
+
});
|
|
30
|
+
return validated;
|
|
31
|
+
}
|
|
32
|
+
async fetchSigningKey(kid) {
|
|
33
|
+
const jClient = await this.fetchJwksClient();
|
|
34
|
+
return new Promise((res, rej) => {
|
|
35
|
+
jClient.getSigningKey(kid, (err, key) => {
|
|
36
|
+
if (err) {
|
|
37
|
+
rej(err);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
res(key.publicKey || key.rsaPublicKey);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async fetchJwksClient() {
|
|
46
|
+
if (!this.jwksClient) {
|
|
47
|
+
this.jwksClient = jwks({
|
|
48
|
+
cache: true,
|
|
49
|
+
cacheMaxEntries: 5,
|
|
50
|
+
cacheMaxAge: 1000 * 60 * 60 * 10,
|
|
51
|
+
jwksUri: this.jwksUri,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return this.jwksClient;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|