@bitblit/ratchet-epsilon-common 4.0.115-alpha → 4.0.119-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/lib/background/background-dynamo-log-table-handler.d.ts +1 -1
- package/lib/background/background-handler.d.ts +1 -1
- package/lib/background/background-http-adapter-handler.d.ts +1 -1
- package/lib/background/background-validator.d.ts +1 -1
- package/lib/build/ratchet-epsilon-common-info.d.ts +1 -1
- package/lib/built-in/daemon/daemon-authorizer-function.d.ts +1 -1
- package/lib/built-in/daemon/daemon-handler.d.ts +2 -2
- package/lib/built-in/daemon/daemon-process-state-list.d.ts +1 -1
- package/lib/built-in/http/built-in-auth-filters.d.ts +1 -1
- package/lib/cli/ratchet-cli-handler.d.ts +2 -2
- package/lib/config/epsilon-logger-config.d.ts +2 -2
- package/lib/config/http/filter-chain-context.d.ts +1 -1
- package/lib/config/http/http-config.d.ts +1 -1
- package/lib/epsilon-global-handler.d.ts +1 -1
- package/lib/epsilon-instance.d.ts +1 -1
- package/lib/epsilon-logging-extension-processor.d.ts +2 -2
- package/lib/http/auth/auth0-web-token-manipulator.d.ts +1 -1
- package/lib/http/auth/google-web-token-manipulator.d.ts +1 -1
- package/lib/http/auth/jwt-ratchet-local-web-token-manipulator.d.ts +2 -2
- package/lib/http/auth/local-web-token-manipulator.d.ts +3 -3
- package/lib/http/auth/web-token-manipulator.d.ts +1 -1
- package/lib/http/event-util.d.ts +1 -1
- package/lib/http/response-util.d.ts +1 -1
- package/lib/http/route/epsilon-router.d.ts +1 -1
- package/lib/http/route/router-util.d.ts +2 -2
- package/lib/index.d.ts +132 -1
- package/lib/index.mjs +344 -0
- package/lib/index.mjs.map +1 -0
- package/lib/local-container-server.d.ts +1 -1
- package/lib/local-server.d.ts +1 -1
- package/lib/sample/test-error-server.d.ts +1 -1
- package/lib/util/epsilon-config-parser.d.ts +1 -1
- package/package.json +18 -19
- package/lib/background/background-dynamo-log-table-handler.js +0 -37
- package/lib/background/background-entry.js +0 -1
- package/lib/background/background-execution-event-type.js +0 -8
- package/lib/background/background-execution-event.js +0 -1
- package/lib/background/background-execution-listener.js +0 -1
- package/lib/background/background-handler.js +0 -273
- package/lib/background/background-http-adapter-handler.js +0 -128
- package/lib/background/background-meta-response-internal.js +0 -1
- package/lib/background/background-process-handling.js +0 -5
- package/lib/background/background-process-log-table-entry.js +0 -1
- package/lib/background/background-queue-response-internal.js +0 -1
- package/lib/background/background-validator.js +0 -86
- package/lib/background/epsilon-background-process-error.js +0 -93
- package/lib/background/internal-background-entry.js +0 -1
- package/lib/background/manager/abstract-background-manager.js +0 -89
- package/lib/background/manager/aws-sqs-sns-background-manager.js +0 -153
- package/lib/background/manager/background-manager-like.js +0 -1
- package/lib/background/manager/background-manager.spec.js +0 -73
- package/lib/background/manager/single-thread-local-background-manager.js +0 -45
- package/lib/background/s3-background-transaction-logger.js +0 -52
- package/lib/build/ratchet-epsilon-common-info.js +0 -14
- package/lib/built-in/background/echo-processor.js +0 -15
- package/lib/built-in/background/log-and-enqueue-echo-processor.js +0 -12
- package/lib/built-in/background/log-message-background-error-processor.js +0 -6
- package/lib/built-in/background/no-op-processor.js +0 -9
- package/lib/built-in/background/retry-processor.js +0 -40
- package/lib/built-in/background/sample-delay-processor.js +0 -13
- package/lib/built-in/background/sample-input-validated-processor-data.js +0 -1
- package/lib/built-in/background/sample-input-validated-processor.js +0 -12
- package/lib/built-in/built-in-trace-id-generators.js +0 -21
- package/lib/built-in/daemon/daemon-authorizer-function.js +0 -1
- package/lib/built-in/daemon/daemon-config.js +0 -1
- package/lib/built-in/daemon/daemon-group-selection-function.js +0 -1
- package/lib/built-in/daemon/daemon-handler.js +0 -59
- package/lib/built-in/daemon/daemon-process-state-list.js +0 -1
- package/lib/built-in/http/apollo-filter.js +0 -59
- package/lib/built-in/http/built-in-auth-filters.js +0 -107
- package/lib/built-in/http/built-in-authorizers.js +0 -39
- package/lib/built-in/http/built-in-filters.js +0 -208
- package/lib/built-in/http/built-in-handlers.js +0 -69
- package/lib/built-in/http/log-level-manipulation-filter.js +0 -16
- package/lib/built-in/http/run-handler-as-filter.js +0 -60
- package/lib/built-in/http/run-handler-as-filter.spec.js +0 -40
- package/lib/cli/ratchet-cli-handler.js +0 -20
- package/lib/cli/run-background-process-from-command-line.js +0 -22
- package/lib/config/background/background-aws-config.js +0 -1
- package/lib/config/background/background-config.js +0 -1
- package/lib/config/background/background-error-processor.js +0 -1
- package/lib/config/background/background-processor.js +0 -1
- package/lib/config/background/background-transaction-log.js +0 -1
- package/lib/config/background/background-transaction-logger.js +0 -1
- package/lib/config/cron/abstract-cron-entry.js +0 -1
- package/lib/config/cron/cron-background-entry.js +0 -1
- package/lib/config/cron/cron-config.js +0 -1
- package/lib/config/dynamo-db-config.js +0 -1
- package/lib/config/epsilon-config.js +0 -1
- package/lib/config/epsilon-lambda-event-handler.js +0 -1
- package/lib/config/epsilon-logger-config.js +0 -1
- package/lib/config/generic-aws-event-handler-function.js +0 -1
- package/lib/config/http/authorizer-function.js +0 -1
- package/lib/config/http/epsilon-authorization-context.js +0 -1
- package/lib/config/http/extended-api-gateway-event.js +0 -1
- package/lib/config/http/filter-chain-context.js +0 -1
- package/lib/config/http/filter-function.js +0 -1
- package/lib/config/http/handler-function.js +0 -1
- package/lib/config/http/http-config.js +0 -1
- package/lib/config/http/http-processing-config.js +0 -1
- package/lib/config/http/mapped-http-processing-config.js +0 -1
- package/lib/config/http/null-returned-object-handling.js +0 -6
- package/lib/config/inter-api/inter-api-aws-config.js +0 -1
- package/lib/config/inter-api/inter-api-config.js +0 -1
- package/lib/config/inter-api/inter-api-process-mapping.js +0 -1
- package/lib/config/logging-trace-id-generator.js +0 -1
- package/lib/config/open-api/open-api-document-components.js +0 -1
- package/lib/config/open-api/open-api-document-path.js +0 -1
- package/lib/config/open-api/open-api-document.js +0 -1
- package/lib/config/s3-config.js +0 -1
- package/lib/config/sns-config.js +0 -1
- package/lib/epsilon-build-properties.js +0 -24
- package/lib/epsilon-constants.js +0 -46
- package/lib/epsilon-global-handler.js +0 -154
- package/lib/epsilon-instance.js +0 -1
- package/lib/epsilon-logging-extension-processor.js +0 -15
- package/lib/http/auth/api-gateway-adapter-authentication-handler.js +0 -72
- package/lib/http/auth/auth0-web-token-manipulator.js +0 -61
- package/lib/http/auth/basic-auth-token.js +0 -1
- package/lib/http/auth/google-web-token-manipulator.js +0 -70
- package/lib/http/auth/google-web-token-manipulator.spec.js +0 -10
- package/lib/http/auth/jwt-ratchet-local-web-token-manipulator.js +0 -27
- package/lib/http/auth/local-web-token-manipulator.js +0 -74
- package/lib/http/auth/local-web-token-manipulator.spec.js +0 -24
- package/lib/http/auth/web-token-manipulator.js +0 -1
- package/lib/http/error/bad-gateway.js +0 -8
- package/lib/http/error/bad-request-error.js +0 -8
- package/lib/http/error/conflict-error.js +0 -8
- package/lib/http/error/epsilon-http-error.js +0 -133
- package/lib/http/error/epsilon-http-error.spec.js +0 -11
- package/lib/http/error/forbidden-error.js +0 -8
- package/lib/http/error/gateway-timeout.js +0 -8
- package/lib/http/error/method-not-allowed-error.js +0 -8
- package/lib/http/error/misconfigured-error.js +0 -8
- package/lib/http/error/not-found-error.js +0 -8
- package/lib/http/error/not-implemented.js +0 -8
- package/lib/http/error/request-timeout-error.js +0 -8
- package/lib/http/error/service-unavailable.js +0 -8
- package/lib/http/error/too-many-requests-error.js +0 -8
- package/lib/http/error/unauthorized-error.js +0 -8
- package/lib/http/event-util.js +0 -176
- package/lib/http/event-util.spec.js +0 -161
- package/lib/http/response-util.js +0 -141
- package/lib/http/response-util.spec.js +0 -92
- package/lib/http/route/epsilon-router.js +0 -1
- package/lib/http/route/extended-auth-response-context.js +0 -1
- package/lib/http/route/route-mapping.js +0 -1
- package/lib/http/route/route-validator-config.js +0 -1
- package/lib/http/route/router-util.js +0 -233
- package/lib/http/route/router-util.spec.js +0 -23
- package/lib/http/web-handler.js +0 -117
- package/lib/http/web-handler.spec.js +0 -32
- package/lib/http/web-v2-handler.js +0 -22
- package/lib/index.js +0 -1
- package/lib/inter-api/inter-api-entry.js +0 -1
- package/lib/inter-api/inter-api-util.js +0 -59
- package/lib/inter-api/inter-api-util.spec.js +0 -61
- package/lib/inter-api-manager.js +0 -65
- package/lib/lambda-event-handler/cron-epsilon-lambda-event-handler.js +0 -73
- package/lib/lambda-event-handler/cron-epsilon-lambda-event-handler.spec.js +0 -50
- package/lib/lambda-event-handler/dynamo-epsilon-lambda-event-handler.js +0 -33
- package/lib/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.js +0 -29
- package/lib/lambda-event-handler/inter-api-epsilon-lambda-event-handler.js +0 -23
- package/lib/lambda-event-handler/s3-epsilon-lambda-event-handler.js +0 -41
- package/lib/local-container-server.js +0 -76
- package/lib/local-server-cert.js +0 -67
- package/lib/local-server.js +0 -162
- package/lib/open-api-util/open-api-doc-modifications.js +0 -1
- package/lib/open-api-util/open-api-doc-modifier.js +0 -79
- package/lib/open-api-util/open-api-doc-modifier.spec.js +0 -16
- package/lib/open-api-util/yaml-combiner.js +0 -27
- package/lib/open-api-util/yaml-combiner.spec.js +0 -22
- package/lib/sample/sample-server-components.js +0 -185
- package/lib/sample/sample-server-static-files.js +0 -593
- package/lib/sample/test-error-server.js +0 -44
- package/lib/util/aws-util.js +0 -65
- package/lib/util/context-util.js +0 -101
- package/lib/util/cron-util.js +0 -68
- package/lib/util/cron-util.spec.js +0 -124
- package/lib/util/epsilon-config-parser.js +0 -65
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { SampleServerComponents } from '../../sample/sample-server-components.js';
|
|
3
|
-
import { RunHandlerAsFilter } from './run-handler-as-filter.js';
|
|
4
|
-
import { RouterUtil } from '../../http/route/router-util.js';
|
|
5
|
-
describe('#routerUtilApplyOpenApiDoc', function () {
|
|
6
|
-
it('should find the most specific route and the least specific', async () => {
|
|
7
|
-
const inst = await SampleServerComponents.createSampleEpsilonGlobalHandler('jest-most specific route');
|
|
8
|
-
expect(inst.epsilon.modelValidator).toBeTruthy();
|
|
9
|
-
const evtFixed = {
|
|
10
|
-
httpMethod: 'get',
|
|
11
|
-
path: '/v0/multi/fixed',
|
|
12
|
-
requestContext: {
|
|
13
|
-
stage: 'v0',
|
|
14
|
-
},
|
|
15
|
-
queryStringParameters: {},
|
|
16
|
-
};
|
|
17
|
-
const evtVar = {
|
|
18
|
-
httpMethod: 'get',
|
|
19
|
-
path: '/v0/multi/xyz',
|
|
20
|
-
requestContext: {
|
|
21
|
-
stage: 'v0',
|
|
22
|
-
},
|
|
23
|
-
queryStringParameters: {},
|
|
24
|
-
};
|
|
25
|
-
const findFixedRP = await inst.epsilon.webHandler.findBestMatchingRoute(evtFixed);
|
|
26
|
-
const findVariableRP = await inst.epsilon.webHandler.findBestMatchingRoute(evtVar);
|
|
27
|
-
const findFixed = await RunHandlerAsFilter.findHandler(findFixedRP, evtFixed, {}, false);
|
|
28
|
-
const findVariable = await RunHandlerAsFilter.findHandler(findVariableRP, evtVar, {}, false);
|
|
29
|
-
expect(findFixed).toBeTruthy();
|
|
30
|
-
expect(findFixed['flag']).toEqual('fixed');
|
|
31
|
-
expect(findVariable).toBeTruthy();
|
|
32
|
-
expect(findVariable['flag']).toEqual('variable');
|
|
33
|
-
Logger.info('done');
|
|
34
|
-
});
|
|
35
|
-
it('should reformat a path to match the other library', function () {
|
|
36
|
-
const inString = '/meta/item/{itemId}';
|
|
37
|
-
const outString = RouterUtil.openApiPathToRouteParserPath(inString);
|
|
38
|
-
expect(outString).toEqual('/meta/item/:itemId');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AbstractRatchetCliHandler } from '@bitblit/ratchet-node-only/lib/cli/abstract-ratchet-cli-handler.js';
|
|
2
|
-
import { RunBackgroundProcessFromCommandLine } from './run-background-process-from-command-line.js';
|
|
3
|
-
import { TestErrorServer } from '../sample/test-error-server.js';
|
|
4
|
-
import { LocalContainerServer } from '../local-container-server.js';
|
|
5
|
-
import { RatchetEpsilonCommonInfo } from '../build/ratchet-epsilon-common-info.js';
|
|
6
|
-
import { LocalServer } from '../local-server.js';
|
|
7
|
-
export class RatchetCliHandler extends AbstractRatchetCliHandler {
|
|
8
|
-
fetchHandlerMap() {
|
|
9
|
-
return {
|
|
10
|
-
'run-background-process': RunBackgroundProcessFromCommandLine.runFromCliArgs,
|
|
11
|
-
'run-test-error-server': TestErrorServer.runFromCliArgs,
|
|
12
|
-
'run-local-container-server': LocalContainerServer.runFromCliArgs,
|
|
13
|
-
'run-sample-local-server': LocalServer.runSampleLocalServerFromCliArgs,
|
|
14
|
-
'run-sample-local-batch-server': LocalServer.runSampleLocalServerFromCliArgs,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
fetchVersionInfo() {
|
|
18
|
-
return RatchetEpsilonCommonInfo.buildInformation();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { BooleanRatchet } from '@bitblit/ratchet-common/lib/lang/boolean-ratchet.js';
|
|
3
|
-
export class RunBackgroundProcessFromCommandLine {
|
|
4
|
-
static async runFromCliArgs(args) {
|
|
5
|
-
if (args.length > 1) {
|
|
6
|
-
const procName = args[0];
|
|
7
|
-
const dryRun = args.length > 1 && BooleanRatchet.parseBool(args[1]);
|
|
8
|
-
const data = args.length > 2 ? JSON.parse(args[2]) : null;
|
|
9
|
-
const meta = args.length > 3 ? JSON.parse(args[3]) : null;
|
|
10
|
-
const epsilon = null;
|
|
11
|
-
if (dryRun) {
|
|
12
|
-
Logger.info('Dry-Run, would have sent : %s %j %j', procName, data, meta);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
await epsilon.processSingleBackgroundByParts(procName, data, meta);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
console.log('Usage : run-background-process {processName} {dryRun true/false} {dataJson} {metaJson}');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export var NullReturnedObjectHandling;
|
|
2
|
-
(function (NullReturnedObjectHandling) {
|
|
3
|
-
NullReturnedObjectHandling["Error"] = "Error";
|
|
4
|
-
NullReturnedObjectHandling["ConvertToEmptyString"] = "ConvertToEmptyString";
|
|
5
|
-
NullReturnedObjectHandling["Return404NotFoundResponse"] = "Return404NotFoundResponse";
|
|
6
|
-
})(NullReturnedObjectHandling || (NullReturnedObjectHandling = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/config/s3-config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/config/sns-config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { StringRatchet } from '@bitblit/ratchet-common/lib/lang/string-ratchet.js';
|
|
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
|
-
}
|
package/lib/epsilon-constants.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { EsmRatchet } from '@bitblit/ratchet-common/lib/lang/esm-ratchet.js';
|
|
3
|
-
export class EpsilonConstants {
|
|
4
|
-
static EPSILON_FINDER_DYNAMIC_IMPORT_PATH_ENV_NAME = 'EPSILON_FINDER_DYNAMIC_IMPORT_PATH';
|
|
5
|
-
static EPSILON_FINDER_FUNCTION_NAME_ENV_NAME = 'EPSILON_FINDER_FUNCTION_NAME';
|
|
6
|
-
static DEFAULT_EPSILON_FINDER_DYNAMIC_IMPORT_PATH = 'epsilon-global-handler-provider.js';
|
|
7
|
-
static DEFAULT_EPSILON_FINDER_FUNCTION_NAME = 'findEpsilonGlobalHandler';
|
|
8
|
-
static AUTH_HEADER_PREFIX = 'Bearer ';
|
|
9
|
-
static AUTH_HEADER_NAME = 'Authorization';
|
|
10
|
-
static BACKGROUND_SQS_TYPE_FIELD = 'BACKGROUND_TYPE';
|
|
11
|
-
static BACKGROUND_SNS_START_MARKER = 'BACKGROUND_START_MARKER';
|
|
12
|
-
static BACKGROUND_SNS_IMMEDIATE_RUN_FLAG = 'BACKGROUND_IMMEDIATE_RUN_FLAG';
|
|
13
|
-
static INTER_API_SNS_EVENT = 'EPSILON_INTER_API_EVENT';
|
|
14
|
-
static load(filePath, className) {
|
|
15
|
-
Logger.info('Searching for %s : %s : %s', filePath, className, EsmRatchet.fetchDirName(import.meta.url));
|
|
16
|
-
let rval = null;
|
|
17
|
-
const val = require(filePath);
|
|
18
|
-
if (val) {
|
|
19
|
-
Logger.debug('Found %s - pulling object : %j : %s', filePath, Object.keys(val), className);
|
|
20
|
-
rval = val[className];
|
|
21
|
-
}
|
|
22
|
-
return rval;
|
|
23
|
-
}
|
|
24
|
-
static async findDynamicImportEpsilonGlobalHandlerProvider() {
|
|
25
|
-
const importPath = process.env[EpsilonConstants.EPSILON_FINDER_DYNAMIC_IMPORT_PATH_ENV_NAME] ||
|
|
26
|
-
EpsilonConstants.DEFAULT_EPSILON_FINDER_DYNAMIC_IMPORT_PATH;
|
|
27
|
-
const fnName = process.env[EpsilonConstants.EPSILON_FINDER_FUNCTION_NAME_ENV_NAME] || EpsilonConstants.DEFAULT_EPSILON_FINDER_FUNCTION_NAME;
|
|
28
|
-
Logger.debug('Using epsilon finder dynamic import path : %s / %s', importPath, fnName);
|
|
29
|
-
let provider = null;
|
|
30
|
-
try {
|
|
31
|
-
provider = this.load(importPath, fnName);
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
Logger.error('Error loading provider : %s / %s : %s', importPath, fnName, err, err);
|
|
35
|
-
}
|
|
36
|
-
let rval = null;
|
|
37
|
-
if (provider) {
|
|
38
|
-
Logger.debug('Type2 is : %s', typeof provider);
|
|
39
|
-
Logger.info('Got3 : %s : %s', provider, typeof provider);
|
|
40
|
-
rval = provider();
|
|
41
|
-
Logger.info('Rval3 is %s', rval);
|
|
42
|
-
}
|
|
43
|
-
return rval;
|
|
44
|
-
}
|
|
45
|
-
constructor() { }
|
|
46
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { EventUtil } from './http/event-util.js';
|
|
3
|
-
import { ErrorRatchet } from '@bitblit/ratchet-common/lib/lang/error-ratchet.js';
|
|
4
|
-
import { LoggerLevelName } from '@bitblit/ratchet-common/lib/logger/logger-level-name.js';
|
|
5
|
-
import { LogMessageFormatType } from '@bitblit/ratchet-common/lib/logger/log-message-format-type.js';
|
|
6
|
-
import { PromiseRatchet } from '@bitblit/ratchet-common/lib/lang/promise-ratchet.js';
|
|
7
|
-
import { TimeoutToken } from '@bitblit/ratchet-common/lib/lang/timeout-token.js';
|
|
8
|
-
import { ResponseUtil } from './http/response-util.js';
|
|
9
|
-
import { EpsilonHttpError } from './http/error/epsilon-http-error.js';
|
|
10
|
-
import { RequestTimeoutError } from './http/error/request-timeout-error.js';
|
|
11
|
-
import { ContextUtil } from './util/context-util.js';
|
|
12
|
-
import { WebV2Handler } from './http/web-v2-handler.js';
|
|
13
|
-
import { InterApiEpsilonLambdaEventHandler } from './lambda-event-handler/inter-api-epsilon-lambda-event-handler.js';
|
|
14
|
-
import { GenericSnsEpsilonLambdaEventHandler } from './lambda-event-handler/generic-sns-epsilon-lambda-event-handler.js';
|
|
15
|
-
import { CronEpsilonLambdaEventHandler } from './lambda-event-handler/cron-epsilon-lambda-event-handler.js';
|
|
16
|
-
import { S3EpsilonLambdaEventHandler } from './lambda-event-handler/s3-epsilon-lambda-event-handler.js';
|
|
17
|
-
import { DynamoEpsilonLambdaEventHandler } from './lambda-event-handler/dynamo-epsilon-lambda-event-handler.js';
|
|
18
|
-
import { EpsilonLoggingExtensionProcessor } from './epsilon-logging-extension-processor.js';
|
|
19
|
-
import { LoggerOutputFunction } from '@bitblit/ratchet-common/lib/logger/logger-output-function.js';
|
|
20
|
-
export class EpsilonGlobalHandler {
|
|
21
|
-
_epsilon;
|
|
22
|
-
static LOGGER_CONFIGURED = false;
|
|
23
|
-
static GLOBAL_INSTANCE_PROVIDER;
|
|
24
|
-
static set globalInstanceProvider(input) {
|
|
25
|
-
EpsilonGlobalHandler.GLOBAL_INSTANCE_PROVIDER = input;
|
|
26
|
-
}
|
|
27
|
-
static get globalInstanceProvider() {
|
|
28
|
-
return EpsilonGlobalHandler.GLOBAL_INSTANCE_PROVIDER;
|
|
29
|
-
}
|
|
30
|
-
handlers = null;
|
|
31
|
-
constructor(_epsilon) {
|
|
32
|
-
this._epsilon = _epsilon;
|
|
33
|
-
if (!EpsilonGlobalHandler.LOGGER_CONFIGURED) {
|
|
34
|
-
EpsilonGlobalHandler.configureDefaultLogger();
|
|
35
|
-
Logger.info('EpsilonLoggingConfiguration:Default logger configured');
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
Logger.info('EpsilonLoggingConfiguration:Skipping default logger config - already configured');
|
|
39
|
-
}
|
|
40
|
-
this.handlers = [
|
|
41
|
-
this._epsilon.webHandler,
|
|
42
|
-
new WebV2Handler(this._epsilon.webHandler),
|
|
43
|
-
this._epsilon.backgroundHandler,
|
|
44
|
-
new InterApiEpsilonLambdaEventHandler(this._epsilon),
|
|
45
|
-
new GenericSnsEpsilonLambdaEventHandler(this._epsilon),
|
|
46
|
-
new CronEpsilonLambdaEventHandler(this._epsilon),
|
|
47
|
-
new S3EpsilonLambdaEventHandler(this._epsilon),
|
|
48
|
-
new DynamoEpsilonLambdaEventHandler(this._epsilon),
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
static configureDefaultLogger(overrides) {
|
|
52
|
-
const output = overrides ? Object.assign({}, overrides) : {};
|
|
53
|
-
output.initialLevel = output.initialLevel ?? LoggerLevelName.info;
|
|
54
|
-
output.formatType = output.formatType ?? LogMessageFormatType.StructuredJson;
|
|
55
|
-
output.globalVars = output.globalVars ?? {};
|
|
56
|
-
output.outputFunction = output.outputFunction ?? LoggerOutputFunction.StdOut;
|
|
57
|
-
output.ringBufferSize = output.ringBufferSize ?? 0;
|
|
58
|
-
const src = output.preProcessors || [];
|
|
59
|
-
output.preProcessors = src.concat([new EpsilonLoggingExtensionProcessor()]);
|
|
60
|
-
const pre = Logger.getOptions();
|
|
61
|
-
Logger.changeDefaultOptions(output, true);
|
|
62
|
-
const post = Logger.getOptions();
|
|
63
|
-
EpsilonGlobalHandler.LOGGER_CONFIGURED = true;
|
|
64
|
-
Logger.info('EpsilonLoggingConfiguration: Updated');
|
|
65
|
-
Logger.dumpOptionsIntoLog();
|
|
66
|
-
}
|
|
67
|
-
get epsilon() {
|
|
68
|
-
return this._epsilon;
|
|
69
|
-
}
|
|
70
|
-
async processSingleBackgroundByParts(type, data, overrideTraceId, overrideTraceDepth) {
|
|
71
|
-
return this.processSingleBackgroundEntry(this._epsilon.backgroundManager.createEntry(type, data), overrideTraceId, overrideTraceDepth);
|
|
72
|
-
}
|
|
73
|
-
async processSingleBackgroundEntry(e, overrideTraceId, overrideTraceDepth) {
|
|
74
|
-
let rval = false;
|
|
75
|
-
if (e?.type) {
|
|
76
|
-
const internal = this._epsilon.backgroundManager.wrapEntryForInternal(e, overrideTraceId, overrideTraceDepth);
|
|
77
|
-
rval = await this._epsilon.backgroundHandler.processSingleBackgroundEntry(internal);
|
|
78
|
-
Logger.info('Direct processed request %j to %s', e, rval);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
Logger.error('Cannot process null/unnamed background entry');
|
|
82
|
-
}
|
|
83
|
-
return rval;
|
|
84
|
-
}
|
|
85
|
-
async lambdaHandler(event, context) {
|
|
86
|
-
let rval = null;
|
|
87
|
-
try {
|
|
88
|
-
if (this.epsilon.config.disableLastResortTimeout || !context || !context.getRemainingTimeInMillis()) {
|
|
89
|
-
rval = await this.innerLambdaHandler(event, context);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
const tmp = await PromiseRatchet.timeout(this.innerLambdaHandler(event, context), 'EpsilonLastResortTimeout', context.getRemainingTimeInMillis() - 1000);
|
|
93
|
-
if (TimeoutToken.isTimeoutToken(tmp)) {
|
|
94
|
-
tmp.writeToLog();
|
|
95
|
-
rval = ResponseUtil.errorResponse(EpsilonHttpError.wrapError(new RequestTimeoutError('Timed out')));
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
rval = tmp;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
finally {
|
|
103
|
-
ContextUtil.clearContext();
|
|
104
|
-
}
|
|
105
|
-
return rval;
|
|
106
|
-
}
|
|
107
|
-
async innerLambdaHandler(event, context) {
|
|
108
|
-
ContextUtil.initContext(this._epsilon, event, context, 'TBD');
|
|
109
|
-
let rval = null;
|
|
110
|
-
let errorHandler = EpsilonGlobalHandler.defaultProcessUncaughtError;
|
|
111
|
-
try {
|
|
112
|
-
if (!this._epsilon) {
|
|
113
|
-
Logger.error('Config not found, abandoning');
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
const logLevel = EventUtil.calcLogLevelViaEventOrEnvParam(Logger.getLevel(), event, this._epsilon.config.loggerConfig);
|
|
117
|
-
Logger.setLevel(logLevel);
|
|
118
|
-
if (this._epsilon.config.loggerConfig &&
|
|
119
|
-
this._epsilon.config.loggerConfig.queryParamTracePrefixName &&
|
|
120
|
-
event.queryStringParameters &&
|
|
121
|
-
event.queryStringParameters[this._epsilon.config.loggerConfig.queryParamTracePrefixName]) {
|
|
122
|
-
Logger.info('Setting trace prefix to %s', event.queryStringParameters[this._epsilon.config.loggerConfig.queryParamTracePrefixName]);
|
|
123
|
-
Logger.updateTracePrefix(event.queryStringParameters[this._epsilon.config.loggerConfig.queryParamTracePrefixName]);
|
|
124
|
-
}
|
|
125
|
-
let found = false;
|
|
126
|
-
for (let i = 0; i < this.handlers.length && !found; i++) {
|
|
127
|
-
const handler = this.handlers[i];
|
|
128
|
-
if (handler.handlesEvent(event)) {
|
|
129
|
-
found = true;
|
|
130
|
-
errorHandler = handler.processUncaughtError || errorHandler;
|
|
131
|
-
const label = handler.extractLabel(event, context);
|
|
132
|
-
ContextUtil.setProcessLabel(label);
|
|
133
|
-
Logger.logByLevel(this._epsilon?.config?.loggerConfig?.epsilonStartEndMessageLogLevel || LoggerLevelName.info, 'EvtStart: %s', label);
|
|
134
|
-
rval = await handler.processEvent(event, context);
|
|
135
|
-
Logger.logByLevel(this._epsilon?.config?.loggerConfig?.epsilonStartEndMessageLogLevel || LoggerLevelName.info, 'EvtEnd: %s', label);
|
|
136
|
-
Logger.silly('EvtEnd:Value: %s Value: %j', label, rval);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
rval = await errorHandler(event, context, err);
|
|
142
|
-
}
|
|
143
|
-
return rval;
|
|
144
|
-
}
|
|
145
|
-
static async defaultProcessUncaughtError(event, context, err) {
|
|
146
|
-
Logger.error('Error slipped out to outer edge (Default). Logging and returning log : %s', err, err);
|
|
147
|
-
const rval = {
|
|
148
|
-
statusCode: 500,
|
|
149
|
-
body: JSON.stringify({ error: ErrorRatchet.safeStringifyErr(err) }),
|
|
150
|
-
isBase64Encoded: false,
|
|
151
|
-
};
|
|
152
|
-
return rval;
|
|
153
|
-
}
|
|
154
|
-
}
|
package/lib/epsilon-instance.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ContextUtil } from './util/context-util.js';
|
|
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
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { LocalWebTokenManipulator } from './local-web-token-manipulator.js';
|
|
3
|
-
import { EpsilonConstants } from '../../epsilon-constants.js';
|
|
4
|
-
export class ApiGatewayAdapterAuthenticationHandler {
|
|
5
|
-
webTokenManipulator;
|
|
6
|
-
constructor(issuer, encryptionKeys) {
|
|
7
|
-
this.webTokenManipulator = new LocalWebTokenManipulator([encryptionKeys], issuer);
|
|
8
|
-
}
|
|
9
|
-
lambdaHandler(event, context, callback) {
|
|
10
|
-
Logger.info('Got event : %j', event);
|
|
11
|
-
const srcString = ApiGatewayAdapterAuthenticationHandler.extractTokenStringFromAuthorizerEvent(event);
|
|
12
|
-
if (srcString) {
|
|
13
|
-
const methodArn = event.methodArn;
|
|
14
|
-
this.webTokenManipulator
|
|
15
|
-
.parseAndValidateJWTStringAsync(srcString)
|
|
16
|
-
.then((parsed) => {
|
|
17
|
-
if (parsed) {
|
|
18
|
-
callback(null, this.createPolicy(methodArn, srcString, parsed));
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
Logger.info('Invalid bearer token');
|
|
22
|
-
callback(new Error('Unauthorized'));
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
.catch((err) => {
|
|
26
|
-
Logger.error('Exception parsing token : %s', err);
|
|
27
|
-
callback(new Error('Unauthorized'));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
Logger.info('Token not supplied');
|
|
32
|
-
callback(new Error('Unauthorized'));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
createPolicy(methodArn, srcString, userOb) {
|
|
36
|
-
const tmp = methodArn.split(':');
|
|
37
|
-
const apiGatewayArnTmp = tmp[5].split('/');
|
|
38
|
-
const awsAccountId = tmp[4];
|
|
39
|
-
const region = tmp[3];
|
|
40
|
-
const stage = apiGatewayArnTmp[1];
|
|
41
|
-
const restApiId = apiGatewayArnTmp[0];
|
|
42
|
-
const response = {
|
|
43
|
-
principalId: 'user',
|
|
44
|
-
policyDocument: {
|
|
45
|
-
Version: '2012-10-17',
|
|
46
|
-
Statement: [
|
|
47
|
-
{
|
|
48
|
-
Action: 'execute-api:Invoke',
|
|
49
|
-
Effect: 'Allow',
|
|
50
|
-
Resource: ['arn:aws:execute-api:' + region + ':' + awsAccountId + ':' + restApiId + '/' + stage + '/*/*'],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
context: {
|
|
55
|
-
userJSON: JSON.stringify(userOb),
|
|
56
|
-
srcData: srcString,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
return response;
|
|
60
|
-
}
|
|
61
|
-
static extractTokenStringFromAuthorizerEvent(event) {
|
|
62
|
-
Logger.silly('Extracting token from event : %j', event);
|
|
63
|
-
let rval = null;
|
|
64
|
-
if (event && event.authorizationToken) {
|
|
65
|
-
const token = event.authorizationToken;
|
|
66
|
-
if (token && token.startsWith(EpsilonConstants.AUTH_HEADER_PREFIX)) {
|
|
67
|
-
rval = token.substring(EpsilonConstants.AUTH_HEADER_PREFIX.length);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return rval;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
|
|
2
|
-
import { StringRatchet } from '@bitblit/ratchet-common/lib/lang/string-ratchet.js';
|
|
3
|
-
import jwt from 'jsonwebtoken';
|
|
4
|
-
import jwks from 'jwks-rsa';
|
|
5
|
-
export class Auth0WebTokenManipulator {
|
|
6
|
-
clientId;
|
|
7
|
-
jwksUri;
|
|
8
|
-
issuer;
|
|
9
|
-
jwksClient;
|
|
10
|
-
constructor(clientId, jwksUri, issuer) {
|
|
11
|
-
this.clientId = clientId;
|
|
12
|
-
this.jwksUri = jwksUri;
|
|
13
|
-
this.issuer = issuer;
|
|
14
|
-
}
|
|
15
|
-
async extractTokenFromAuthorizationHeader(authHeader) {
|
|
16
|
-
let tokenString = StringRatchet.trimToEmpty(authHeader);
|
|
17
|
-
if (tokenString.toLowerCase().startsWith('bearer ')) {
|
|
18
|
-
tokenString = tokenString.substring(7);
|
|
19
|
-
}
|
|
20
|
-
const validated = tokenString ? await this.parseAndValidateAuth0Token(tokenString, false) : null;
|
|
21
|
-
return validated;
|
|
22
|
-
}
|
|
23
|
-
async parseAndValidateAuth0Token(auth0Token, allowExpired = false) {
|
|
24
|
-
Logger.debug('Validating Auth0 token : %s', StringRatchet.obscure(auth0Token, 4));
|
|
25
|
-
const fullToken = jwt.decode(auth0Token, { complete: true });
|
|
26
|
-
const kid = fullToken?.header?.kid;
|
|
27
|
-
const nowEpochSeconds = Math.floor(new Date().getTime() / 1000);
|
|
28
|
-
const pubKey = await this.fetchSigningKey(kid);
|
|
29
|
-
const validated = jwt.verify(auth0Token, pubKey, {
|
|
30
|
-
audience: this.clientId,
|
|
31
|
-
issuer: this.issuer,
|
|
32
|
-
ignoreExpiration: allowExpired,
|
|
33
|
-
clockTimestamp: nowEpochSeconds,
|
|
34
|
-
});
|
|
35
|
-
return validated;
|
|
36
|
-
}
|
|
37
|
-
async fetchSigningKey(kid) {
|
|
38
|
-
const jClient = await this.fetchJwksClient();
|
|
39
|
-
return new Promise((res, rej) => {
|
|
40
|
-
jClient.getSigningKey(kid, (err, key) => {
|
|
41
|
-
if (err) {
|
|
42
|
-
rej(err);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
res(key.publicKey || key.rsaPublicKey);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async fetchJwksClient() {
|
|
51
|
-
if (!this.jwksClient) {
|
|
52
|
-
this.jwksClient = jwks({
|
|
53
|
-
cache: true,
|
|
54
|
-
cacheMaxEntries: 5,
|
|
55
|
-
cacheMaxAge: 1000 * 60 * 60 * 10,
|
|
56
|
-
jwksUri: this.jwksUri,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return this.jwksClient;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|