aws-lambda-api-tools 0.1.7 → 0.1.9
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/bin/bootstrap-iam.js +1 -11
- package/package.json +11 -8
- package/bin/bootstrap-iam.ts +0 -56
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/lib/authorization-helper.d.ts +0 -3
- package/dist/lib/authorization-helper.d.ts.map +0 -1
- package/dist/lib/authorization-helper.js +0 -14
- package/dist/lib/authorization-helper.js.map +0 -1
- package/dist/lib/cf-yaml-helper.d.ts +0 -26
- package/dist/lib/cf-yaml-helper.d.ts.map +0 -1
- package/dist/lib/cf-yaml-helper.js +0 -158
- package/dist/lib/cf-yaml-helper.js.map +0 -1
- package/dist/lib/custom-error.d.ts +0 -8
- package/dist/lib/custom-error.d.ts.map +0 -1
- package/dist/lib/custom-error.js +0 -19
- package/dist/lib/custom-error.js.map +0 -1
- package/dist/lib/lambda-route-proxy-entry-handler.d.ts +0 -10
- package/dist/lib/lambda-route-proxy-entry-handler.d.ts.map +0 -1
- package/dist/lib/lambda-route-proxy-entry-handler.js +0 -72
- package/dist/lib/lambda-route-proxy-entry-handler.js.map +0 -1
- package/dist/lib/lambda-route-proxy-path-not-found.d.ts +0 -3
- package/dist/lib/lambda-route-proxy-path-not-found.d.ts.map +0 -1
- package/dist/lib/lambda-route-proxy-path-not-found.js +0 -22
- package/dist/lib/lambda-route-proxy-path-not-found.js.map +0 -1
- package/dist/lib/middlewares/route-module-jwt-validation-middleware.d.ts +0 -4
- package/dist/lib/middlewares/route-module-jwt-validation-middleware.d.ts.map +0 -1
- package/dist/lib/middlewares/route-module-jwt-validation-middleware.js +0 -32
- package/dist/lib/middlewares/route-module-jwt-validation-middleware.js.map +0 -1
- package/dist/lib/middlewares/route-module-schema-validation-middleware.d.ts +0 -4
- package/dist/lib/middlewares/route-module-schema-validation-middleware.d.ts.map +0 -1
- package/dist/lib/middlewares/route-module-schema-validation-middleware.js +0 -72
- package/dist/lib/middlewares/route-module-schema-validation-middleware.js.map +0 -1
- package/dist/lib/swagger-route-specification-generator.d.ts +0 -18
- package/dist/lib/swagger-route-specification-generator.d.ts.map +0 -1
- package/dist/lib/swagger-route-specification-generator.js +0 -125
- package/dist/lib/swagger-route-specification-generator.js.map +0 -1
- package/dist/lib/swagger-specification-types.d.ts +0 -142
- package/dist/lib/swagger-specification-types.d.ts.map +0 -1
- package/dist/lib/swagger-specification-types.js +0 -3
- package/dist/lib/swagger-specification-types.js.map +0 -1
- package/dist/lib/types-and-interfaces.d.ts +0 -78
- package/dist/lib/types-and-interfaces.d.ts.map +0 -1
- package/dist/lib/types-and-interfaces.js +0 -3
- package/dist/lib/types-and-interfaces.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -17
- package/dist/lib/utils.js.map +0 -1
package/bin/bootstrap-iam.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// Register ts-node with esm support
|
|
4
|
-
require('ts-node').register({
|
|
5
|
-
transpileOnly: true,
|
|
6
|
-
compilerOptions: {
|
|
7
|
-
module: 'commonjs'
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
// Run the TypeScript file
|
|
12
|
-
require('./bootstrap-iam.ts');
|
|
2
|
+
"use strict";var t=require("aws-cdk-lib"),e=require("aws-cdk-lib/aws-iam"),s=require("child_process");console.log("Starting GitHub OIDC IAM setup...");var i=process.argv.slice(2),c=i.find(o=>o.startsWith("--repo=")),n=i.find(o=>o.startsWith("--policy="));c||(console.error("Error: --repo argument is required"),console.error("Usage: gh-oidc-iam --repo=owner/repo-name [--policy=PolicyName]"),console.error("Example: gh-oidc-iam --repo=myorg/my-repo --policy=AdministratorAccess"),process.exit(1));var a=c.split("=")[1],l=n?n.split("=")[1]:"AdministratorAccess";console.log(`Configuring for repository: ${a}`);console.log(`Using policy: ${l}`);var p=new t.App,r=class extends t.Stack{constructor(m,d,g){super(m,d,g),console.log("Creating OIDC Provider...");let u=new e.CfnOIDCProvider(this,"GithubOidcProvider",{url:"https://token.actions.githubusercontent.com",clientIdList:["sts.amazonaws.com"],thumbprintList:["6938fd4d98bab03faadb97b34396831e3780aea1","1c58a3a8518e8759bf075b76b750d4f2df264fcd"]});console.log("Creating IAM Role...");let y=new e.Role(this,"GithubActionsRole",{assumedBy:new e.WebIdentityPrincipal(u.attrArn,{StringEquals:{"token.actions.githubusercontent.com:aud":"sts.amazonaws.com"},StringLike:{"token.actions.githubusercontent.com:sub":`repo:${a}:*`}}),managedPolicies:[e.ManagedPolicy.fromAwsManagedPolicyName(l)]});new t.CfnOutput(this,"RoleArn",{value:y.roleArn,description:"ARN of role to use in GitHub Actions"})}};console.log("Creating CloudFormation stack...");new r(p,"GithubActionsIam");console.log("Synthesizing CloudFormation template...");var f=p.synth();console.log("Starting deployment...");try{let o=["cdk deploy","GithubActionsIam","--require-approval never",`--app "${f.directory}"`].join(" ");console.log(`Executing: ${o}`),(0,s.execSync)(o,{stdio:"inherit",env:{...process.env,AWS_REGION:process.env.AWS_REGION||"us-east-1"}}),console.log("Deployment completed successfully!")}catch(o){console.error("Deployment failed:",o),process.exit(1)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-lambda-api-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "
|
|
12
|
+
"build": "node -r esbuild-register scripts/build-binaries.ts",
|
|
13
|
+
"prepare": "npm run build",
|
|
13
14
|
"bump-version": "npm run build && npm version patch -m 'Updated version to %s [skip ci]'",
|
|
14
15
|
"test": "jest",
|
|
15
16
|
"generate-swagger": "node -r ts-node/register bin/generate-swagger.js",
|
|
@@ -31,11 +32,13 @@
|
|
|
31
32
|
"@types/minimist": "^1.2.5",
|
|
32
33
|
"@types/node": "^15.14.9",
|
|
33
34
|
"@types/node-fetch": "^2.6.12",
|
|
34
|
-
"esbuild": "^0.
|
|
35
|
+
"esbuild": "^0.19.0",
|
|
36
|
+
"esbuild-register": "^3.5.0",
|
|
35
37
|
"jest": "^29.7.0",
|
|
36
38
|
"nodemon": "^2.0.22",
|
|
37
39
|
"prettier": "^2.8.8",
|
|
38
|
-
"ts-jest": "^29.2.5"
|
|
40
|
+
"ts-jest": "^29.2.5",
|
|
41
|
+
"typescript": "~4.9.5"
|
|
39
42
|
},
|
|
40
43
|
"dependencies": {
|
|
41
44
|
"@types/atob": "^2.1.2",
|
|
@@ -46,7 +49,8 @@
|
|
|
46
49
|
"@types/minimist": "^1.2.2",
|
|
47
50
|
"@types/node-fetch": "^2.5.12",
|
|
48
51
|
"atob": "^2.1.2",
|
|
49
|
-
"aws-cdk
|
|
52
|
+
"aws-cdk": "^2.178.2",
|
|
53
|
+
"aws-cdk-lib": "^2.0.0",
|
|
50
54
|
"axios": "^1.6.3",
|
|
51
55
|
"joi": "^17.12.3",
|
|
52
56
|
"joi-to-swagger": "6.2.0",
|
|
@@ -54,11 +58,10 @@
|
|
|
54
58
|
"js-yaml": "^4.1.0",
|
|
55
59
|
"lodash": "^4.17.21",
|
|
56
60
|
"minimist": "^1.2.6",
|
|
57
|
-
"ts-node": "^10.9.1"
|
|
58
|
-
"typescript": "^5.0.0"
|
|
61
|
+
"ts-node": "^10.9.1"
|
|
59
62
|
},
|
|
60
63
|
"files": [
|
|
61
|
-
"bin",
|
|
64
|
+
"bin/*.js",
|
|
62
65
|
"dist"
|
|
63
66
|
]
|
|
64
67
|
}
|
package/bin/bootstrap-iam.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
import { App, Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
|
|
3
|
-
import { OpenIdConnectProvider, Role, WebIdentityPrincipal, ManagedPolicy } from 'aws-cdk-lib/aws-iam';
|
|
4
|
-
|
|
5
|
-
// Parse command line arguments
|
|
6
|
-
const args = process.argv.slice(2);
|
|
7
|
-
const repoArg = args.find(arg => arg.startsWith('--repo='));
|
|
8
|
-
const policyArg = args.find(arg => arg.startsWith('--policy='));
|
|
9
|
-
|
|
10
|
-
if (!repoArg) {
|
|
11
|
-
console.error('Error: --repo argument is required');
|
|
12
|
-
console.error('Usage: gh-oidc-iam --repo=owner/repo-name [--policy=PolicyName]');
|
|
13
|
-
console.error('Example: gh-oidc-iam --repo=myorg/my-repo --policy=AdministratorAccess');
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const repoName = repoArg.split('=')[1];
|
|
18
|
-
const policyName = policyArg ? policyArg.split('=')[1] : 'AdministratorAccess';
|
|
19
|
-
|
|
20
|
-
const app = new App();
|
|
21
|
-
|
|
22
|
-
class GithubActionsIamStack extends Stack {
|
|
23
|
-
constructor(scope: App, id: string, props?: StackProps) {
|
|
24
|
-
super(scope, id, props);
|
|
25
|
-
|
|
26
|
-
const githubOidcProvider = new OpenIdConnectProvider(this, 'GithubOidcProvider', {
|
|
27
|
-
url: 'https://token.actions.githubusercontent.com',
|
|
28
|
-
clientIds: ['sts.amazonaws.com'],
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const deploymentRole = new Role(this, 'GithubActionsRole', {
|
|
32
|
-
assumedBy: new WebIdentityPrincipal(
|
|
33
|
-
githubOidcProvider.openIdConnectProviderArn,
|
|
34
|
-
{
|
|
35
|
-
StringEquals: {
|
|
36
|
-
'token.actions.githubusercontent.com:aud': 'sts.amazonaws.com',
|
|
37
|
-
},
|
|
38
|
-
StringLike: {
|
|
39
|
-
'token.actions.githubusercontent.com:sub': `repo:${repoName}:*`,
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
),
|
|
43
|
-
managedPolicies: [
|
|
44
|
-
ManagedPolicy.fromAwsManagedPolicyName(policyName),
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
new CfnOutput(this, 'RoleArn', {
|
|
49
|
-
value: deploymentRole.roleArn,
|
|
50
|
-
description: 'ARN of role to use in GitHub Actions',
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
new GithubActionsIamStack(app, 'GithubActionsIam');
|
|
56
|
-
app.synth();
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { BaseResponseObject, BaseRouteResponse, MiddlewareArgumentsInputFunction, MiddlewareChain, MiddlewareSchemaInputFunction, ResponseData, ResponseError, ResponseObject, RouteArguments, RouteModule, RouteResponse, RouteSchema, ConfigRouteEntry, RouteConfig, Permission, } from './lib/types-and-interfaces';
|
|
2
|
-
export { CustomError } from './lib/custom-error';
|
|
3
|
-
export { lambdaRouteProxyEntryHandler } from './lib/lambda-route-proxy-entry-handler';
|
|
4
|
-
export { lambdaRouteProxyPathNotFound } from './lib/lambda-route-proxy-path-not-found';
|
|
5
|
-
export { schemaValidationMiddleware } from './lib/middlewares/route-module-schema-validation-middleware';
|
|
6
|
-
export { jwtValidationMiddleware } from './lib/middlewares/route-module-jwt-validation-middleware';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gCAAgC,EAChC,eAAe,EACf,6BAA6B,EAC7B,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,UAAU,GACX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAEvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAEzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtValidationMiddleware = exports.schemaValidationMiddleware = exports.lambdaRouteProxyPathNotFound = exports.lambdaRouteProxyEntryHandler = exports.CustomError = void 0;
|
|
4
|
-
var custom_error_1 = require("./lib/custom-error");
|
|
5
|
-
Object.defineProperty(exports, "CustomError", { enumerable: true, get: function () { return custom_error_1.CustomError; } });
|
|
6
|
-
var lambda_route_proxy_entry_handler_1 = require("./lib/lambda-route-proxy-entry-handler");
|
|
7
|
-
Object.defineProperty(exports, "lambdaRouteProxyEntryHandler", { enumerable: true, get: function () { return lambda_route_proxy_entry_handler_1.lambdaRouteProxyEntryHandler; } });
|
|
8
|
-
var lambda_route_proxy_path_not_found_1 = require("./lib/lambda-route-proxy-path-not-found");
|
|
9
|
-
Object.defineProperty(exports, "lambdaRouteProxyPathNotFound", { enumerable: true, get: function () { return lambda_route_proxy_path_not_found_1.lambdaRouteProxyPathNotFound; } });
|
|
10
|
-
var route_module_schema_validation_middleware_1 = require("./lib/middlewares/route-module-schema-validation-middleware");
|
|
11
|
-
Object.defineProperty(exports, "schemaValidationMiddleware", { enumerable: true, get: function () { return route_module_schema_validation_middleware_1.schemaValidationMiddleware; } });
|
|
12
|
-
var route_module_jwt_validation_middleware_1 = require("./lib/middlewares/route-module-jwt-validation-middleware");
|
|
13
|
-
Object.defineProperty(exports, "jwtValidationMiddleware", { enumerable: true, get: function () { return route_module_jwt_validation_middleware_1.jwtValidationMiddleware; } });
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAkBA,mDAAiD;AAAxC,2GAAA,WAAW,OAAA;AAEpB,2FAAsF;AAA7E,gJAAA,4BAA4B,OAAA;AAErC,6FAAuF;AAA9E,iJAAA,4BAA4B,OAAA;AAErC,yHAAyG;AAAhG,uJAAA,0BAA0B,OAAA;AAEnC,mHAAmG;AAA1F,iJAAA,uBAAuB,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-helper.d.ts","sourceRoot":"","sources":["../../src/lib/authorization-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,eAAO,MAAM,cAAc,UAAW,sBAAsB,SAO3D,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authorizeRoute = void 0;
|
|
4
|
-
// import { CustomError } from './custom-error';
|
|
5
|
-
const authorizeRoute = (event) => {
|
|
6
|
-
// extract token
|
|
7
|
-
const token = event.headers.authorization;
|
|
8
|
-
if (!token) {
|
|
9
|
-
// throw new CustomError('Request is unauthenticated. No bearer token exists.', 401);
|
|
10
|
-
}
|
|
11
|
-
// implement authorize check with jwt from issuer
|
|
12
|
-
};
|
|
13
|
-
exports.authorizeRoute = authorizeRoute;
|
|
14
|
-
//# sourceMappingURL=authorization-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-helper.js","sourceRoot":"","sources":["../../src/lib/authorization-helper.ts"],"names":[],"mappings":";;;AACA,gDAAgD;AAEzC,MAAM,cAAc,GAAG,CAAC,KAA6B,EAAE,EAAE;IAC9D,gBAAgB;IAChB,MAAM,KAAK,GAAW,KAAK,CAAC,OAAQ,CAAC,aAAuB,CAAC;IAC7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,qFAAqF;IACvF,CAAC;IACD,iDAAiD;AACnD,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parser and schema for CloudFormation YAML template tags.
|
|
3
|
-
*
|
|
4
|
-
* There are some existing modules out there:
|
|
5
|
-
* https://github.com/yyolk/cloudformation-js-yaml-schema
|
|
6
|
-
* https://github.com/KoharaKazuya/js-yaml-schema-cfn
|
|
7
|
-
* But both are poorly documented, with insufficient tests, and don't fully work.
|
|
8
|
-
*
|
|
9
|
-
* This implementation is based on the official AWS python client:
|
|
10
|
-
* https://github.com/aws/aws-cli/blob/develop/awscli/customizations/cloudformation/yamlhelper.py
|
|
11
|
-
*/
|
|
12
|
-
import jsYaml from 'js-yaml';
|
|
13
|
-
/**
|
|
14
|
-
* The actual js-yaml schema, extending the DEFAULT_SAFE_SCHEMA.
|
|
15
|
-
*/
|
|
16
|
-
export declare const schema: jsYaml.Schema;
|
|
17
|
-
/**
|
|
18
|
-
* Convenience function to parse the given yaml input.
|
|
19
|
-
*/
|
|
20
|
-
export declare const parse: (input: any) => unknown;
|
|
21
|
-
/**
|
|
22
|
-
* Convenience function to serialize the given object to Yaml.
|
|
23
|
-
*/
|
|
24
|
-
export declare const dump: (input: any) => string;
|
|
25
|
-
export declare const updateCFYamlPropertyInplace: (pathToYaml: string, propertyPath: string, propertyValue: string) => void;
|
|
26
|
-
//# sourceMappingURL=cf-yaml-helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cf-yaml-helper.d.ts","sourceRoot":"","sources":["../../src/lib/cf-yaml-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,MAAM,MAAM,SAAS,CAAC;AAsF5B;;GAEG;AACH,eAAO,MAAM,MAAM,eAGjB,CAAC;AAGH;;GAEG;AACH,eAAO,MAAM,KAAK,UAAW,GAAG,YAA2C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,IAAI,UAAW,GAAG,WAA2C,CAAC;AAG5E,eAAO,MAAM,2BAA2B,eAAgB,MAAM,gBAAgB,MAAM,iBAAiB,MAAM,SAU1G,CAAC"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Parser and schema for CloudFormation YAML template tags.
|
|
4
|
-
*
|
|
5
|
-
* There are some existing modules out there:
|
|
6
|
-
* https://github.com/yyolk/cloudformation-js-yaml-schema
|
|
7
|
-
* https://github.com/KoharaKazuya/js-yaml-schema-cfn
|
|
8
|
-
* But both are poorly documented, with insufficient tests, and don't fully work.
|
|
9
|
-
*
|
|
10
|
-
* This implementation is based on the official AWS python client:
|
|
11
|
-
* https://github.com/aws/aws-cli/blob/develop/awscli/customizations/cloudformation/yamlhelper.py
|
|
12
|
-
*/
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
-
var ownKeys = function(o) {
|
|
31
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
-
var ar = [];
|
|
33
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
-
return ar;
|
|
35
|
-
};
|
|
36
|
-
return ownKeys(o);
|
|
37
|
-
};
|
|
38
|
-
return function (mod) {
|
|
39
|
-
if (mod && mod.__esModule) return mod;
|
|
40
|
-
var result = {};
|
|
41
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
-
__setModuleDefault(result, mod);
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
})();
|
|
46
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.updateCFYamlPropertyInplace = exports.dump = exports.parse = exports.schema = void 0;
|
|
51
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
52
|
-
const fs = __importStar(require("fs"));
|
|
53
|
-
const _ = __importStar(require("lodash"));
|
|
54
|
-
/**
|
|
55
|
-
* Split a string on the given separator just once, returning an array of two parts, or null.
|
|
56
|
-
*/
|
|
57
|
-
const splitOne = (str, sep) => {
|
|
58
|
-
let index = str.indexOf(sep);
|
|
59
|
-
return index < 0 ? null : [str.slice(0, index), str.slice(index + sep.length)];
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Returns true if obj is a representation of a CloudFormation intrinsic, i.e. an object with a
|
|
63
|
-
* single property at key keyName.
|
|
64
|
-
*/
|
|
65
|
-
const checkType = (obj, keyName) => {
|
|
66
|
-
return obj && typeof obj === 'object' && Object.keys(obj).length === 1 &&
|
|
67
|
-
obj.hasOwnProperty(keyName);
|
|
68
|
-
};
|
|
69
|
-
const overrides = {
|
|
70
|
-
// ShortHand notation for !GetAtt accepts Resource.Attribute format while the standard notation
|
|
71
|
-
// is to use an array [Resource, Attribute]. Convert shorthand to standard format.
|
|
72
|
-
GetAtt: {
|
|
73
|
-
parse: (data) => typeof data === 'string' ? splitOne(data, '.') : data,
|
|
74
|
-
dump: (data) => data.join('.')
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const applyOverrides = (data, tag, method) => {
|
|
78
|
-
return overrides[tag] ? overrides[tag][method](data) : data;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Generic tag-creating helper. For the given name of the form 'Fn::Something' (or just
|
|
82
|
-
* 'Something'), creates a js-yaml Type object that can parse and dump this type. It creates it
|
|
83
|
-
* for all types of values, for simplicity and because that's how the official Python version
|
|
84
|
-
* works.
|
|
85
|
-
*/
|
|
86
|
-
const makeTagTypes = (name) => {
|
|
87
|
-
const parts = splitOne(name, '::');
|
|
88
|
-
const tag = parts ? parts[1] : name;
|
|
89
|
-
// Translate in the same way for all types, to match Python's generic translation.
|
|
90
|
-
return ['scalar', 'sequence', 'mapping'].map((kind) => new js_yaml_1.default.Type('!' + tag, {
|
|
91
|
-
kind: kind,
|
|
92
|
-
construct: (data) => ({ [name]: applyOverrides(data, tag, 'parse') }),
|
|
93
|
-
predicate: (obj) => checkType(obj, name),
|
|
94
|
-
represent: (obj) => applyOverrides(obj[name], tag, 'dump'),
|
|
95
|
-
}));
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* This list is from
|
|
99
|
-
* http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
|
|
100
|
-
* Note that the Python version handles ANY tag that starts with ! in the same way (translating it
|
|
101
|
-
* to Fn:: prefix, but js-yaml requires listing tags explicitly.
|
|
102
|
-
*/
|
|
103
|
-
const supportedFunctions = [
|
|
104
|
-
'Fn::Base64',
|
|
105
|
-
'Fn::Cidr',
|
|
106
|
-
'Fn::FindInMap',
|
|
107
|
-
'Fn::GetAtt',
|
|
108
|
-
'Fn::GetAZs',
|
|
109
|
-
'Fn::ImportValue',
|
|
110
|
-
'Fn::Join',
|
|
111
|
-
'Fn::Select',
|
|
112
|
-
'Fn::Split',
|
|
113
|
-
'Fn::Sub',
|
|
114
|
-
'Fn::Transform',
|
|
115
|
-
'Ref',
|
|
116
|
-
'Condition',
|
|
117
|
-
'Fn::And',
|
|
118
|
-
'Fn::Equals',
|
|
119
|
-
'Fn::If',
|
|
120
|
-
'Fn::Not',
|
|
121
|
-
'Fn::Or',
|
|
122
|
-
];
|
|
123
|
-
const allTagTypes = [];
|
|
124
|
-
for (let name of supportedFunctions) {
|
|
125
|
-
allTagTypes.push(...makeTagTypes(name));
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* The actual js-yaml schema, extending the DEFAULT_SAFE_SCHEMA.
|
|
129
|
-
*/
|
|
130
|
-
exports.schema = js_yaml_1.default.CORE_SCHEMA.extend({
|
|
131
|
-
implicit: [],
|
|
132
|
-
explicit: allTagTypes,
|
|
133
|
-
});
|
|
134
|
-
/**
|
|
135
|
-
* Convenience function to parse the given yaml input.
|
|
136
|
-
*/
|
|
137
|
-
const parse = (input) => js_yaml_1.default.load(input, { schema: exports.schema });
|
|
138
|
-
exports.parse = parse;
|
|
139
|
-
;
|
|
140
|
-
/**
|
|
141
|
-
* Convenience function to serialize the given object to Yaml.
|
|
142
|
-
*/
|
|
143
|
-
const dump = (input) => js_yaml_1.default.dump(input, { schema: exports.schema });
|
|
144
|
-
exports.dump = dump;
|
|
145
|
-
const updateCFYamlPropertyInplace = (pathToYaml, propertyPath, propertyValue) => {
|
|
146
|
-
try {
|
|
147
|
-
const doc = (0, exports.parse)(fs.readFileSync(pathToYaml, 'utf8'));
|
|
148
|
-
// console.log(`${doc}`);
|
|
149
|
-
_.set(doc, propertyPath, propertyValue);
|
|
150
|
-
fs.writeFileSync(pathToYaml, (0, exports.dump)(doc));
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
console.log('--- ERROR: Could not perform yaml update. ---');
|
|
154
|
-
console.log(JSON.stringify(e));
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
exports.updateCFYamlPropertyInplace = updateCFYamlPropertyInplace;
|
|
158
|
-
//# sourceMappingURL=cf-yaml-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cf-yaml-helper.js","sourceRoot":"","sources":["../../src/lib/cf-yaml-helper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAA6B;AAC7B,uCAAyB;AACzB,0CAA4B;AAE3B;;GAEG;AACH,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE;IAC5C,IAAI,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACjF,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,OAAe,EAAE,EAAE;IAC9C,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC;QACpE,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC;AAGF,MAAM,SAAS,GAAQ;IACrB,+FAA+F;IAC/F,kFAAkF;IAClF,MAAM,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;QACzB,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QACxC,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAA,YAAI,EAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,2BAA2B,+BAUtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/lib/custom-error.ts"],"names":[],"mappings":"AACE,qBAAa,WAAY,SAAQ,KAAK;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;gBAEL,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAM/C,IAAI,cAAc,WAEjB;IAED,IAAa,OAAO,WAEnB;CACF"}
|
package/dist/lib/custom-error.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomError = void 0;
|
|
4
|
-
class CustomError extends Error {
|
|
5
|
-
constructor(message, statusCode) {
|
|
6
|
-
super(message);
|
|
7
|
-
this._httpStatusCode = statusCode || 500;
|
|
8
|
-
this._message = message;
|
|
9
|
-
}
|
|
10
|
-
get httpStatusCode() {
|
|
11
|
-
return this._httpStatusCode;
|
|
12
|
-
}
|
|
13
|
-
get message() {
|
|
14
|
-
return this._message;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.CustomError = CustomError;
|
|
18
|
-
;
|
|
19
|
-
//# sourceMappingURL=custom-error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/lib/custom-error.ts"],"names":[],"mappings":";;;AACE,MAAa,WAAY,SAAQ,KAAK;IAIpC,YAAY,OAAe,EAAE,UAAkB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,eAAe,GAAG,UAAU,IAAI,GAAG,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAa,OAAO;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAjBD,kCAiBC;AAAA,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { APIGatewayProxyEventV2 } from 'aws-lambda';
|
|
2
|
-
import { RouteConfig, RouteArguments, RouteModule } from './types-and-interfaces';
|
|
3
|
-
export declare const getRouteModule: (config: RouteConfig, method: string, path: string, availableRouteModules: {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}) => RouteModule;
|
|
6
|
-
export declare const getRouteModuleResult: ({ routeChain }: RouteModule, incoming: RouteArguments) => Promise<any>;
|
|
7
|
-
export declare const lambdaRouteProxyEntryHandler: (config: RouteConfig, availableRouteModules: {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}) => (event: APIGatewayProxyEventV2) => Promise<{}>;
|
|
10
|
-
//# sourceMappingURL=lambda-route-proxy-entry-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-route-proxy-entry-handler.d.ts","sourceRoot":"","sources":["../../src/lib/lambda-route-proxy-entry-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAoB,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAYpG,eAAO,MAAM,cAAc,WAAY,WAAW,UAAU,MAAM,QAAQ,MAAM,yBAAyB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,KAAG,WAUjI,CAAC;AAEF,eAAO,MAAM,oBAAoB,mBAA0B,WAAW,YAAY,cAAc,KAAG,OAAO,CAAC,GAAG,CAM7G,CAAC;AAEF,eAAO,MAAM,4BAA4B,WAAY,WAAW,yBAAyB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,aAC/F,sBAAsB,gBA+CnC,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lambdaRouteProxyEntryHandler = exports.getRouteModuleResult = exports.getRouteModule = void 0;
|
|
4
|
-
const custom_error_1 = require("./custom-error");
|
|
5
|
-
const authorization_helper_1 = require("./authorization-helper");
|
|
6
|
-
const getRouteConfigEntry = (config, method, path) => config.routes.find(r => r.path.toLowerCase() === path.toLowerCase() && r.method.toLowerCase() === method.toLowerCase());
|
|
7
|
-
const shouldAuthorizeRoute = (routesConfig, routeConfigEntry) => (routesConfig.authorizeAllRoutes && routeConfigEntry.authorizeRoute !== false)
|
|
8
|
-
||
|
|
9
|
-
routeConfigEntry.authorizeRoute === true;
|
|
10
|
-
const getRouteModule = (config, method, path, availableRouteModules) => {
|
|
11
|
-
const routeEntry = getRouteConfigEntry(config, method, path);
|
|
12
|
-
let routeModule = null;
|
|
13
|
-
console.log(`route entry: ${JSON.stringify(routeEntry)}`);
|
|
14
|
-
if (routeEntry) {
|
|
15
|
-
const matchingRouteModuleMapKey = Object.keys(availableRouteModules).find((k) => routeEntry.handlerPath.endsWith(k));
|
|
16
|
-
// routeModule = availableRouteModules[routeEntry.handlerPath.split('/').reverse()[0]];
|
|
17
|
-
routeModule = availableRouteModules[matchingRouteModuleMapKey];
|
|
18
|
-
}
|
|
19
|
-
return routeModule;
|
|
20
|
-
};
|
|
21
|
-
exports.getRouteModule = getRouteModule;
|
|
22
|
-
const getRouteModuleResult = async ({ routeChain }, incoming) => {
|
|
23
|
-
let returnValue = incoming;
|
|
24
|
-
for (const chainFn of routeChain) {
|
|
25
|
-
returnValue = await chainFn(returnValue);
|
|
26
|
-
}
|
|
27
|
-
return returnValue;
|
|
28
|
-
};
|
|
29
|
-
exports.getRouteModuleResult = getRouteModuleResult;
|
|
30
|
-
const lambdaRouteProxyEntryHandler = (config, availableRouteModules) => async (event) => {
|
|
31
|
-
console.log(`Event Data: ${JSON.stringify(event)}`);
|
|
32
|
-
const { routeKey, queryStringParameters, pathParameters, body, isBase64Encoded, } = event;
|
|
33
|
-
let retVal = {};
|
|
34
|
-
try {
|
|
35
|
-
const [method = '', path = ''] = routeKey.split(' ');
|
|
36
|
-
if (shouldAuthorizeRoute(config, getRouteConfigEntry(config, method, path))) {
|
|
37
|
-
await (0, authorization_helper_1.authorizeRoute)(event);
|
|
38
|
-
}
|
|
39
|
-
const routeModule = (0, exports.getRouteModule)(config, method, path, availableRouteModules);
|
|
40
|
-
console.log(`isBase64Encoded: ${isBase64Encoded}`);
|
|
41
|
-
console.log(`body: ${body}`);
|
|
42
|
-
const decodedBody = isBase64Encoded ? Buffer.from(body, 'base64').toString('utf-8') : undefined;
|
|
43
|
-
console.log(`decodedBody:
|
|
44
|
-
${decodedBody}`);
|
|
45
|
-
retVal = await (0, exports.getRouteModuleResult)(routeModule, {
|
|
46
|
-
query: queryStringParameters,
|
|
47
|
-
params: pathParameters,
|
|
48
|
-
body: body ? decodedBody || JSON.parse(body) : undefined,
|
|
49
|
-
rawEvent: event,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
console.error(JSON.stringify({ error, stack: error.stack }));
|
|
54
|
-
if (error instanceof custom_error_1.CustomError) {
|
|
55
|
-
retVal = {
|
|
56
|
-
statusCode: error.httpStatusCode,
|
|
57
|
-
headers: { 'Content-Type': 'application/json' },
|
|
58
|
-
body: error.message,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
retVal = {
|
|
63
|
-
statusCode: 500,
|
|
64
|
-
headers: { 'Content-Type': 'application/json' },
|
|
65
|
-
body: error.message || JSON.stringify(error),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return retVal;
|
|
70
|
-
};
|
|
71
|
-
exports.lambdaRouteProxyEntryHandler = lambdaRouteProxyEntryHandler;
|
|
72
|
-
//# sourceMappingURL=lambda-route-proxy-entry-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-route-proxy-entry-handler.js","sourceRoot":"","sources":["../../src/lib/lambda-route-proxy-entry-handler.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAE7C,iEAAwD;AAExD,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAE,MAAc,EAAE,IAAY,EAAE,EAAE,CAChF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE,CAAqB,CAAC;AAE9I,MAAM,oBAAoB,GAAG,CAAC,YAAyB,EAAE,gBAAkC,EAAE,EAAE,CAC7F,CAAC,YAAY,CAAC,kBAAkB,IAAI,gBAAgB,CAAC,cAAc,KAAK,KAAK,CAAC;;QAE9E,gBAAgB,CAAC,cAAc,KAAK,IAAI,CAAC;AAGpC,MAAM,cAAc,GAAG,CAAC,MAAmB,EAAE,MAAc,EAAE,IAAY,EAAE,qBAA6C,EAAe,EAAE;IAC9I,MAAM,UAAU,GAAG,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7D,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,gBAAgB,IA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UAAU,EAAE,GAAG;gBACf,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;aAC7C,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAhDS,QAAA,4BAA4B,gCAgDrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-route-proxy-path-not-found.d.ts","sourceRoot":"","sources":["../../src/lib/lambda-route-proxy-path-not-found.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAiBhC,eAAO,MAAM,4BAA4B,EAAE,WAG1C,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lambdaRouteProxyPathNotFound = void 0;
|
|
4
|
-
const handler = async (input) => {
|
|
5
|
-
if (input.rawEvent.requestContext.http.method === 'OPTIONS') {
|
|
6
|
-
return {
|
|
7
|
-
statusCode: 200,
|
|
8
|
-
headers: {
|
|
9
|
-
'Access-Control-Allow-Origin': '*',
|
|
10
|
-
'Access-Control-Allow-Methods': '*',
|
|
11
|
-
'Access-Control-Allow-Headers': '*',
|
|
12
|
-
'Access-Control-Max-Age': 300,
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return { statusCode: 404, body: JSON.stringify('Not found') };
|
|
17
|
-
};
|
|
18
|
-
exports.lambdaRouteProxyPathNotFound = {
|
|
19
|
-
routeChain: [handler],
|
|
20
|
-
routeSchema: {},
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=lambda-route-proxy-path-not-found.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-route-proxy-path-not-found.js","sourceRoot":"","sources":["../../src/lib/lambda-route-proxy-path-not-found.ts"],"names":[],"mappings":";;;AAKA,MAAM,OAAO,GAAG,KAAK,EAAE,KAAqB,EAAgB,EAAE;IAC5D,IAAI,KAAK,CAAC,QAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC7D,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO,EAAE;gBACP,6BAA6B,EAAE,GAAG;gBAClC,8BAA8B,EAAE,GAAG;gBACnC,8BAA8B,EAAE,GAAG;gBACnC,wBAAwB,EAAE,GAAG;aAC9B;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;AAChE,CAAC,CAAC;AAEW,QAAA,4BAA4B,GAAgB;IACvD,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,WAAW,EAAE,EAAE;CAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-module-jwt-validation-middleware.d.ts","sourceRoot":"","sources":["../../../src/lib/middlewares/route-module-jwt-validation-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAIzD,eAAO,MAAM,uBAAuB,iBAAkB,cAAc,KAAG,cAuBtE,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtValidationMiddleware = void 0;
|
|
4
|
-
const custom_error_1 = require("../custom-error");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const jwtValidationMiddleware = (incomingData) => {
|
|
7
|
-
const { routeData = {} } = incomingData;
|
|
8
|
-
const authHeader = incomingData.rawEvent.headers['authorization'];
|
|
9
|
-
if (!authHeader) {
|
|
10
|
-
throw new custom_error_1.CustomError('No authorization header provided.', 401);
|
|
11
|
-
}
|
|
12
|
-
const tokenString = authHeader.replace('Bearer ', '');
|
|
13
|
-
const jwt = (0, utils_1.parseJwt)(tokenString);
|
|
14
|
-
console.log(`Decoded token: ${JSON.stringify(jwt)}`);
|
|
15
|
-
if (!jwt) {
|
|
16
|
-
throw new custom_error_1.CustomError('Token not valid.', 401);
|
|
17
|
-
}
|
|
18
|
-
if (!jwt.email_verified) {
|
|
19
|
-
throw new custom_error_1.CustomError('Email for this account has not been verified.', 401);
|
|
20
|
-
}
|
|
21
|
-
if ((jwt.exp * 1000) < Date.now()) {
|
|
22
|
-
throw new custom_error_1.CustomError('Session token is expired.', 403);
|
|
23
|
-
}
|
|
24
|
-
if (!jwt || !(jwt.email && jwt.email_verified)) {
|
|
25
|
-
throw new custom_error_1.CustomError('Token not valid.', 401);
|
|
26
|
-
}
|
|
27
|
-
routeData.jwt = jwt;
|
|
28
|
-
return { ...incomingData, routeData };
|
|
29
|
-
};
|
|
30
|
-
exports.jwtValidationMiddleware = jwtValidationMiddleware;
|
|
31
|
-
exports.default = exports.jwtValidationMiddleware;
|
|
32
|
-
//# sourceMappingURL=route-module-jwt-validation-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-module-jwt-validation-middleware.js","sourceRoot":"","sources":["../../../src/lib/middlewares/route-module-jwt-validation-middleware.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAC9C,oCAAoC;AAE7B,MAAM,uBAAuB,GAAG,CAAC,YAA4B,EAAkB,EAAE;IACtF,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,YAAY,CAAC;IACxC,MAAM,UAAU,GAAG,YAAY,CAAC,QAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,0BAAW,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,WAAW,GAAG,UAAW,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAA,gBAAQ,EAAC,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,0BAAW,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,IAAI,0BAAW,CAAC,+CAA+C,EAAE,GAAG,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAClC,MAAM,IAAI,0BAAW,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,0BAAW,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,SAAS,CAAC,GAAG,GAAG,GAAG,CAAC;IACpB,OAAO,EAAE,GAAG,YAAY,EAAE,SAAS,EAAE,CAAC;AACxC,CAAC,CAAC;AAvBW,QAAA,uBAAuB,2BAuBlC;AAEF,kBAAe,+BAAuB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RouteArguments, RouteSchema } from '../types-and-interfaces';
|
|
2
|
-
export declare const schemaValidationMiddleware: (routeSchema: RouteSchema) => (incomingData: RouteArguments) => RouteArguments;
|
|
3
|
-
export default schemaValidationMiddleware;
|
|
4
|
-
//# sourceMappingURL=route-module-schema-validation-middleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-module-schema-validation-middleware.d.ts","sourceRoot":"","sources":["../../../src/lib/middlewares/route-module-schema-validation-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtE,eAAO,MAAM,0BAA0B,gBAAiB,WAAW,oBAAoB,cAAc,KAAG,cAwDvG,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.schemaValidationMiddleware = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const custom_error_1 = require("../custom-error");
|
|
9
|
-
const schemaValidationMiddleware = (routeSchema) => (incomingData) => {
|
|
10
|
-
console.log(JSON.stringify(incomingData));
|
|
11
|
-
let { params, body, query, ...rest } = incomingData;
|
|
12
|
-
params = params || {};
|
|
13
|
-
body = body || {};
|
|
14
|
-
query = query || {};
|
|
15
|
-
const { params: sParams, requestBody: sBody, query: sQuery } = routeSchema;
|
|
16
|
-
const validatedOutput = {};
|
|
17
|
-
const errorMap = {
|
|
18
|
-
params: [],
|
|
19
|
-
body: [],
|
|
20
|
-
query: [],
|
|
21
|
-
};
|
|
22
|
-
if (sParams) {
|
|
23
|
-
console.log(`params schema: ${JSON.stringify(sParams)}`);
|
|
24
|
-
console.log(`params data: ${JSON.stringify(params)}`);
|
|
25
|
-
try {
|
|
26
|
-
validatedOutput.params = joi_1.default.attempt(params, joi_1.default.compile(sParams), { abortEarly: false });
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
console.error(`sParams Error: ${JSON.stringify(err)}`);
|
|
30
|
-
errorMap.params.push(...err.details.map((d) => d.message));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (sBody) {
|
|
34
|
-
console.log(`body schema: ${JSON.stringify(sBody)}`);
|
|
35
|
-
console.log(`body data: ${JSON.stringify(body)}`);
|
|
36
|
-
try {
|
|
37
|
-
validatedOutput.body = joi_1.default.attempt(body, joi_1.default.compile(sBody), { allowUnknown: true, abortEarly: false });
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
console.error(`sBody Error: ${JSON.stringify(err)}`);
|
|
41
|
-
errorMap.body.push(...err.details.map((d) => d.message));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (sQuery) {
|
|
45
|
-
console.log(`query schema: ${JSON.stringify(sQuery)}`);
|
|
46
|
-
console.log(`query data: ${JSON.stringify(query)}`);
|
|
47
|
-
try {
|
|
48
|
-
validatedOutput.query = joi_1.default.attempt(query, joi_1.default.compile(sQuery), { abortEarly: false });
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
console.error(`sQuery Error: ${JSON.stringify(err)}`);
|
|
52
|
-
errorMap.query.push(...err.details.map((d) => d.message));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (errorMap.body.length || errorMap.params.length || errorMap.query.length) {
|
|
56
|
-
const validationErrorMessage = `The request contains validation errors.
|
|
57
|
-
${errorMap.params.length ? 'Path Parameters:\n' + errorMap.params.join('\n') : ''}
|
|
58
|
-
${errorMap.query.length ? 'Querystring Parameters:\n' + errorMap.query.join('\n') : ''}
|
|
59
|
-
${errorMap.body.length ? 'Request Body:\n' + errorMap.body.join('\n') : ''}
|
|
60
|
-
`;
|
|
61
|
-
throw new custom_error_1.CustomError(validationErrorMessage, 400);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return {
|
|
65
|
-
...validatedOutput,
|
|
66
|
-
...rest,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
exports.schemaValidationMiddleware = schemaValidationMiddleware;
|
|
71
|
-
exports.default = exports.schemaValidationMiddleware;
|
|
72
|
-
//# sourceMappingURL=route-module-schema-validation-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-module-schema-validation-middleware.js","sourceRoot":"","sources":["../../../src/lib/middlewares/route-module-schema-validation-middleware.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AAEtB,kDAA8C;AAEvC,MAAM,0BAA0B,GAAG,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,YAA4B,EAAkB,EAAE;IACvH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;IAC1C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,YAAY,CAAC;IACpD,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;IACtB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAClB,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;IAC3E,MAAM,eAAe,GAAmB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG;QACf,MAAM,EAAE,EAAgB;QACxB,IAAI,EAAE,EAAgB;QACtB,KAAK,EAAE,EAAgB;KACxB,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC;YACH,eAAe,CAAC,MAAM,GAAG,aAAG,CAAC,OAAO,CAAC,MAAM,EAAE,aAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE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,eAAe;YAClB,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAxDW,QAAA,0BAA0B,8BAwDrC;AAEF,kBAAe,kCAA0B,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ComponentsSchema } from 'joi-to-swagger';
|
|
2
|
-
import { ConfigRouteEntry, RouteSchema } from './types-and-interfaces';
|
|
3
|
-
import * as swaggerTypes from './swagger-specification-types';
|
|
4
|
-
type RouteSpecType = {
|
|
5
|
-
path: {
|
|
6
|
-
description: string;
|
|
7
|
-
operationId?: string;
|
|
8
|
-
parameters?: Array<swaggerTypes.ParameterObject>;
|
|
9
|
-
requestBody?: swaggerTypes.RequestBody;
|
|
10
|
-
responses?: Record<string, swaggerTypes.ResponseObject>;
|
|
11
|
-
};
|
|
12
|
-
components: {
|
|
13
|
-
schemas: Record<string, ComponentsSchema>;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const generateRouteSwaggerSpec: (schema: RouteSchema, routeEntry: ConfigRouteEntry) => RouteSpecType;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=swagger-route-specification-generator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-route-specification-generator.d.ts","sourceRoot":"","sources":["../../src/lib/swagger-route-specification-generator.ts"],"names":[],"mappings":"AACA,OAAqB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAE9D,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QACjD,WAAW,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC;QACvC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;KACzD,CAAC;IACF,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;KAC3C,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAAY,WAAW,cAAc,gBAAgB,KAAG,aAsF5F,CAAC"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.generateRouteSwaggerSpec = void 0;
|
|
40
|
-
const joi = __importStar(require("joi"));
|
|
41
|
-
const joi_to_swagger_1 = __importDefault(require("joi-to-swagger"));
|
|
42
|
-
const generateRouteSwaggerSpec = (schema, routeEntry) => {
|
|
43
|
-
const { requestBody: requestBodyJoiSchema, query: queryJoiSchema, params: pathParamsJoiSchema, responseBody: responseBodyJoiSchema } = { requestBody: {}, query: {}, params: {}, responseBody: {}, ...schema };
|
|
44
|
-
const { description, swaggerMethodName } = routeEntry;
|
|
45
|
-
// console.log('schema:')
|
|
46
|
-
// console.log(schema);
|
|
47
|
-
let parameters = [];
|
|
48
|
-
let requestBody = undefined;
|
|
49
|
-
let responseBody = { description: 'Default response' };
|
|
50
|
-
// let requestBodyRefKey: string | undefined;
|
|
51
|
-
// let responseBodyRefKey: string | undefined;
|
|
52
|
-
let componentSchemas = {};
|
|
53
|
-
if (pathParamsJoiSchema && Object.keys(pathParamsJoiSchema).length > 0) {
|
|
54
|
-
const pathParamsKeys = Object.keys(pathParamsJoiSchema);
|
|
55
|
-
const pathParamsSwaggerParameters = pathParamsKeys.map((key) => ({
|
|
56
|
-
name: key,
|
|
57
|
-
in: 'path',
|
|
58
|
-
required: true,
|
|
59
|
-
schema: (0, joi_to_swagger_1.default)(pathParamsJoiSchema[key]).swagger,
|
|
60
|
-
}));
|
|
61
|
-
parameters = Array().concat(parameters, pathParamsSwaggerParameters);
|
|
62
|
-
}
|
|
63
|
-
if (queryJoiSchema && Object.keys(queryJoiSchema).length > 0) {
|
|
64
|
-
const queryKeys = Object.keys(queryJoiSchema);
|
|
65
|
-
const queryParamsSwaggerParameters = queryKeys.map((key) => {
|
|
66
|
-
const { presence } = queryJoiSchema[key]._flags;
|
|
67
|
-
return {
|
|
68
|
-
name: key,
|
|
69
|
-
in: 'query',
|
|
70
|
-
required: presence === 'required',
|
|
71
|
-
schema: (0, joi_to_swagger_1.default)(queryJoiSchema[key]).swagger,
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
parameters = Array().concat(parameters, queryParamsSwaggerParameters);
|
|
75
|
-
}
|
|
76
|
-
if (requestBodyJoiSchema && Object.keys(requestBodyJoiSchema).length > 0) {
|
|
77
|
-
const { swagger, components: requestComponent } = (0, joi_to_swagger_1.default)(joi.isSchema(requestBodyJoiSchema) ? requestBodyJoiSchema : joi.object(requestBodyJoiSchema));
|
|
78
|
-
requestBody = {
|
|
79
|
-
description: 'Default response body',
|
|
80
|
-
content: {
|
|
81
|
-
'application/json': {
|
|
82
|
-
schema: swagger,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
// console.log(swagger);
|
|
87
|
-
if (swagger.$ref || (swagger.items && swagger.items.$ref)) {
|
|
88
|
-
// requestBodyRefKey = swagger.$ref.split('/').reverse()[0];
|
|
89
|
-
componentSchemas = { ...componentSchemas, ...requestComponent.schemas };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (responseBodyJoiSchema && Object.keys(responseBodyJoiSchema).length > 0) {
|
|
93
|
-
const { swagger, components: responseComponent } = (0, joi_to_swagger_1.default)(joi.isSchema(responseBodyJoiSchema) ? responseBodyJoiSchema : joi.object(responseBodyJoiSchema));
|
|
94
|
-
// console.log(JSON.stringify(j2s, null, 2));
|
|
95
|
-
// console.log(swagger);
|
|
96
|
-
responseBody = {
|
|
97
|
-
description: 'Default response body',
|
|
98
|
-
content: {
|
|
99
|
-
'application/json': {
|
|
100
|
-
schema: swagger,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
if (swagger.$ref || (swagger.items && swagger.items.$ref)) {
|
|
105
|
-
// responseBodyRefKey = swagger.$ref.split('/').reverse()[0];
|
|
106
|
-
componentSchemas = { ...componentSchemas, ...responseComponent.schemas };
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
path: {
|
|
111
|
-
description,
|
|
112
|
-
operationId: swaggerMethodName || undefined,
|
|
113
|
-
parameters,
|
|
114
|
-
requestBody,
|
|
115
|
-
responses: {
|
|
116
|
-
'200': responseBody,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
components: {
|
|
120
|
-
schemas: componentSchemas,
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
exports.generateRouteSwaggerSpec = generateRouteSwaggerSpec;
|
|
125
|
-
//# sourceMappingURL=swagger-route-specification-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-route-specification-generator.js","sourceRoot":"","sources":["../../src/lib/swagger-route-specification-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,oEAAgE;AAiBzD,MAAM,wBAAwB,GAAG,CAAC,MAAmB,EAAE,UAA4B,EAAiB,EAAE;IAC3G,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,qBAAqB,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;IAC/M,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC;IACtD,yBAAyB;IACzB,uBAAuB;IACvB,IAAI,UAAU,GAAwC,EAAE,CAAC;IAC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,MAAM,EAAE,OAAO;iBAChB;aACF;SACF,CAAC;QACF,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,6DAA6D;YAC7D,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,iBAAkB,CAAC,OAAO,EAAE,CAAC;QAC5E,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE;YACJ,WAAW;YACX,WAAW,EAAE,iBAAiB,IAAI,SAAS;YAC3C,UAAU;YACV,WAAW;YACX,SAAS,EAAE;gBACT,KAAK,EAAE,YAAY;aACpB;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,gBAAgB;SAC1B;KACF,CAAC;AACJ,CAAC,CAAC;AAtFW,QAAA,wBAAwB,4BAsFnC"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import type { URL } from 'url';
|
|
2
|
-
export interface OpenAPI2 {
|
|
3
|
-
swagger: string;
|
|
4
|
-
paths?: Record<string, PathItemObject>;
|
|
5
|
-
definitions?: Record<string, SchemaObject>;
|
|
6
|
-
parameters?: ParameterObject[];
|
|
7
|
-
responses?: Record<string, ResponseObject>;
|
|
8
|
-
}
|
|
9
|
-
export interface OpenAPI3 {
|
|
10
|
-
openapi: string;
|
|
11
|
-
paths?: Record<string, PathItemObject>;
|
|
12
|
-
components?: {
|
|
13
|
-
schemas?: Record<string, ReferenceObject | SchemaObject>;
|
|
14
|
-
responses?: Record<string, ReferenceObject | ResponseObject>;
|
|
15
|
-
parameters?: Record<string, ReferenceObject | ParameterObject>;
|
|
16
|
-
requestBodies?: Record<string, ReferenceObject | RequestBody>;
|
|
17
|
-
headers?: Record<string, ReferenceObject | HeaderObject>;
|
|
18
|
-
links?: Record<string, ReferenceObject | LinkObject>;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export interface HeaderObject {
|
|
22
|
-
type?: string;
|
|
23
|
-
description?: string;
|
|
24
|
-
required?: boolean;
|
|
25
|
-
schema: ReferenceObject | SchemaObject;
|
|
26
|
-
}
|
|
27
|
-
export interface PathItemObject {
|
|
28
|
-
$ref?: string;
|
|
29
|
-
summary?: string;
|
|
30
|
-
description?: string;
|
|
31
|
-
get?: OperationObject;
|
|
32
|
-
put?: OperationObject;
|
|
33
|
-
post?: OperationObject;
|
|
34
|
-
delete?: OperationObject;
|
|
35
|
-
options?: OperationObject;
|
|
36
|
-
head?: OperationObject;
|
|
37
|
-
patch?: OperationObject;
|
|
38
|
-
trace?: OperationObject;
|
|
39
|
-
parameters?: (ReferenceObject | ParameterObject)[];
|
|
40
|
-
}
|
|
41
|
-
export interface LinkObject {
|
|
42
|
-
operationRef?: string;
|
|
43
|
-
operationId?: string;
|
|
44
|
-
parameters?: (ReferenceObject | ParameterObject)[];
|
|
45
|
-
requestBody?: RequestBody;
|
|
46
|
-
description?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface OperationObject {
|
|
49
|
-
description?: string;
|
|
50
|
-
tags?: string[];
|
|
51
|
-
summary?: string;
|
|
52
|
-
operationId?: string;
|
|
53
|
-
parameters?: (ReferenceObject | ParameterObject)[];
|
|
54
|
-
requestBody?: ReferenceObject | RequestBody;
|
|
55
|
-
responses?: Record<string, ReferenceObject | ResponseObject>;
|
|
56
|
-
}
|
|
57
|
-
export interface ParameterObject {
|
|
58
|
-
name?: string;
|
|
59
|
-
in?: "query" | "header" | "path" | /* V3 */ "cookie" | /* V2 */ "formData" | /* V2 */ "body";
|
|
60
|
-
description?: string;
|
|
61
|
-
required?: boolean;
|
|
62
|
-
deprecated?: boolean;
|
|
63
|
-
schema?: ReferenceObject | SchemaObject;
|
|
64
|
-
type?: "string" | "number" | "integer" | "boolean" | "array" | "file";
|
|
65
|
-
items?: ReferenceObject | SchemaObject;
|
|
66
|
-
enum?: string[];
|
|
67
|
-
}
|
|
68
|
-
export type ReferenceObject = {
|
|
69
|
-
$ref: string;
|
|
70
|
-
};
|
|
71
|
-
export interface ResponseObject {
|
|
72
|
-
description?: string;
|
|
73
|
-
headers?: Record<string, ReferenceObject | HeaderObject>;
|
|
74
|
-
schema?: ReferenceObject | SchemaObject;
|
|
75
|
-
links?: Record<string, ReferenceObject | LinkObject>;
|
|
76
|
-
content?: {
|
|
77
|
-
[contentType: string]: {
|
|
78
|
-
schema: ReferenceObject | SchemaObject;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export interface RequestBody {
|
|
83
|
-
description?: string;
|
|
84
|
-
content?: {
|
|
85
|
-
[contentType: string]: {
|
|
86
|
-
schema: ReferenceObject | SchemaObject;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export interface SchemaObject {
|
|
91
|
-
title?: string;
|
|
92
|
-
description?: string;
|
|
93
|
-
required?: string[];
|
|
94
|
-
enum?: string[];
|
|
95
|
-
type?: string;
|
|
96
|
-
items?: ReferenceObject | SchemaObject;
|
|
97
|
-
allOf?: SchemaObject;
|
|
98
|
-
properties?: Record<string, ReferenceObject | SchemaObject>;
|
|
99
|
-
default?: any;
|
|
100
|
-
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
|
101
|
-
nullable?: boolean;
|
|
102
|
-
oneOf?: (ReferenceObject | SchemaObject)[];
|
|
103
|
-
anyOf?: (ReferenceObject | SchemaObject)[];
|
|
104
|
-
format?: string;
|
|
105
|
-
}
|
|
106
|
-
export type SchemaFormatter = (schemaObj: SchemaObject) => string | undefined;
|
|
107
|
-
export interface SwaggerToTSOptions {
|
|
108
|
-
/** Allow arbitrary properties on schemas (default: false) */
|
|
109
|
-
additionalProperties?: boolean;
|
|
110
|
-
/** (optional) Specify auth if using openapi-typescript to fetch URL */
|
|
111
|
-
auth?: string;
|
|
112
|
-
/** (optional) Specify current working directory (cwd) to resolve remote schemas on disk (not needed for remote URL schemas) */
|
|
113
|
-
cwd?: URL;
|
|
114
|
-
/** Specify a formatter */
|
|
115
|
-
formatter?: SchemaFormatter;
|
|
116
|
-
/** Generates immutable types (readonly properties and readonly array) */
|
|
117
|
-
immutableTypes?: boolean;
|
|
118
|
-
/** (optional) Treat schema objects with default values as non-nullable */
|
|
119
|
-
defaultNonNullable?: boolean;
|
|
120
|
-
/** (optional) Path to Prettier config */
|
|
121
|
-
prettierConfig?: string;
|
|
122
|
-
/** (optional) Parsing input document as raw schema rather than OpenAPI document */
|
|
123
|
-
rawSchema?: boolean;
|
|
124
|
-
/** (optional) Should logging be suppressed? (necessary for STDOUT) */
|
|
125
|
-
silent?: boolean;
|
|
126
|
-
/** (optional) OpenAPI version. Must be present if parsing raw schema */
|
|
127
|
-
version?: number;
|
|
128
|
-
}
|
|
129
|
-
/** Context passed to all submodules */
|
|
130
|
-
export interface GlobalContext {
|
|
131
|
-
additionalProperties: boolean;
|
|
132
|
-
auth?: string;
|
|
133
|
-
formatter?: SchemaFormatter;
|
|
134
|
-
immutableTypes: boolean;
|
|
135
|
-
defaultNonNullable: boolean;
|
|
136
|
-
/** (optional) Should logging be suppressed? (necessary for STDOUT) */
|
|
137
|
-
silent?: boolean;
|
|
138
|
-
namespace?: string;
|
|
139
|
-
rawSchema: boolean;
|
|
140
|
-
version: number;
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=swagger-specification-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-specification-types.d.ts","sourceRoot":"","sources":["../../src/lib/swagger-specification-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,S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"file":"swagger-specification-types.js","sourceRoot":"","sources":["../../src/lib/swagger-specification-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { APIGatewayProxyEventV2 } from 'aws-lambda';
|
|
2
|
-
import { Schema } from 'joi';
|
|
3
|
-
import * as swaggerTypes from './swagger-specification-types';
|
|
4
|
-
export type ConfigRouteEntry = {
|
|
5
|
-
functionName?: string;
|
|
6
|
-
description: string;
|
|
7
|
-
swaggerMethodName?: string;
|
|
8
|
-
path: string;
|
|
9
|
-
method: 'ANY' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT';
|
|
10
|
-
generateOpenApiDocs: boolean;
|
|
11
|
-
handlerPath: string;
|
|
12
|
-
authorizeRoute?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type RouteConfig = {
|
|
15
|
-
authorizeAllRoutes?: boolean;
|
|
16
|
-
routes: Array<ConfigRouteEntry>;
|
|
17
|
-
};
|
|
18
|
-
export type RouteArguments = {
|
|
19
|
-
params?: any;
|
|
20
|
-
body?: any;
|
|
21
|
-
query?: any;
|
|
22
|
-
form?: any;
|
|
23
|
-
rawEvent?: APIGatewayProxyEventV2;
|
|
24
|
-
routeData?: any;
|
|
25
|
-
};
|
|
26
|
-
export interface RouteSchema {
|
|
27
|
-
params?: {
|
|
28
|
-
[key: string]: Schema<any>;
|
|
29
|
-
};
|
|
30
|
-
query?: {
|
|
31
|
-
[key: string]: Schema<any>;
|
|
32
|
-
};
|
|
33
|
-
form?: {
|
|
34
|
-
[key: string]: Schema<any>;
|
|
35
|
-
};
|
|
36
|
-
requestBody?: Schema<any> | {
|
|
37
|
-
[key: string]: Schema<any>;
|
|
38
|
-
};
|
|
39
|
-
responseBody?: Schema<any> | {
|
|
40
|
-
[key: string]: Schema<any>;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export interface BaseResponseObject extends swaggerTypes.ResponseObject {
|
|
44
|
-
}
|
|
45
|
-
export interface ResponseError extends swaggerTypes.ResponseObject {
|
|
46
|
-
error: {
|
|
47
|
-
statusCode: string;
|
|
48
|
-
message: string;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export interface ResponseData extends swaggerTypes.ResponseObject {
|
|
52
|
-
data: any;
|
|
53
|
-
}
|
|
54
|
-
export type ResponseObject<T> = ResponseData | ResponseError;
|
|
55
|
-
export type BaseRouteResponse<T> = {
|
|
56
|
-
[key in '201' | '202' | '203' | '204' | '205' | '206' | '400' | '401' | '402' | '403' | '404' | '405' | '406' | '407' | '408' | '409' | '410' | '411' | '412' | '413' | '414' | '415' | '416' | '417' | '418' | '419']: ResponseObject<T>;
|
|
57
|
-
};
|
|
58
|
-
export interface RouteResponse<T> extends BaseRouteResponse<T> {
|
|
59
|
-
'200': ResponseObject<T>;
|
|
60
|
-
}
|
|
61
|
-
export type MiddlewareSchemaInputFunction = (input: RouteSchema) => RouteArguments;
|
|
62
|
-
export type MiddlewareArgumentsInputFunction = (input: RouteArguments) => any;
|
|
63
|
-
export type MiddlewareChain = Array<MiddlewareArgumentsInputFunction>;
|
|
64
|
-
export type RouteModule = {
|
|
65
|
-
routeChain: MiddlewareChain;
|
|
66
|
-
routeSchema: RouteSchema;
|
|
67
|
-
};
|
|
68
|
-
export interface Permission {
|
|
69
|
-
id: string;
|
|
70
|
-
systemPermission: string;
|
|
71
|
-
enabled: boolean;
|
|
72
|
-
humanReadableName: string;
|
|
73
|
-
entity: {
|
|
74
|
-
level: string;
|
|
75
|
-
humanReadableName: string;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=types-and-interfaces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-and-interfaces.d.ts","sourceRoot":"","sources":["../../src/lib/types-and-interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,M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,CAAC;AAC9E,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,eAAe,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-and-interfaces.js","sourceRoot":"","sources":["../../src/lib/types-and-interfaces.ts"],"names":[],"mappings":""}
|
package/dist/lib/utils.d.ts
DELETED
package/dist/lib/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,UAAW,MAAM,QAQrC,CAAC"}
|
package/dist/lib/utils.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parseJwt = void 0;
|
|
7
|
-
const atob_1 = __importDefault(require("atob"));
|
|
8
|
-
const parseJwt = (token) => {
|
|
9
|
-
var base64Url = token.includes('.') ? token.split('.')[1] : token;
|
|
10
|
-
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
11
|
-
var jsonPayload = decodeURIComponent((0, atob_1.default)(base64).split('').map(function (c) {
|
|
12
|
-
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
13
|
-
}).join(''));
|
|
14
|
-
return JSON.parse(jsonPayload);
|
|
15
|
-
};
|
|
16
|
-
exports.parseJwt = parseJwt;
|
|
17
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/lib/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuC;AAEhC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,IAAI,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,IAAI,MAAM,GAAG,SAAU,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9D,IAAI,WAAW,GAAG,kBAAkB,CAAC,IAAA,cAAI,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAS,CAAS;QAC9E,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEb,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC,CAAC;AARW,QAAA,QAAQ,YAQnB"}
|