aws-lambda-api-tools 0.1.15 → 0.1.16

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.
Files changed (58) hide show
  1. package/bin/bootstrap-iam.js +1 -1
  2. package/dist/bin/bootstrap-iam.d.ts +2 -0
  3. package/dist/bin/bootstrap-iam.d.ts.map +1 -0
  4. package/dist/bin/bootstrap-iam.js +81 -0
  5. package/dist/bin/bootstrap-iam.js.map +1 -0
  6. package/dist/bin/cli.d.ts +2 -0
  7. package/dist/bin/cli.d.ts.map +1 -0
  8. package/dist/bin/cli.js +32 -0
  9. package/dist/bin/cli.js.map +1 -0
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +14 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/lib/authorization-helper.d.ts +3 -0
  15. package/dist/lib/authorization-helper.d.ts.map +1 -0
  16. package/dist/lib/authorization-helper.js +14 -0
  17. package/dist/lib/authorization-helper.js.map +1 -0
  18. package/dist/lib/cf-yaml-helper.d.ts +26 -0
  19. package/dist/lib/cf-yaml-helper.d.ts.map +1 -0
  20. package/dist/lib/cf-yaml-helper.js +148 -0
  21. package/dist/lib/cf-yaml-helper.js.map +1 -0
  22. package/dist/lib/custom-error.d.ts +8 -0
  23. package/dist/lib/custom-error.d.ts.map +1 -0
  24. package/dist/lib/custom-error.js +19 -0
  25. package/dist/lib/custom-error.js.map +1 -0
  26. package/dist/lib/lambda-route-proxy-entry-handler.d.ts +10 -0
  27. package/dist/lib/lambda-route-proxy-entry-handler.d.ts.map +1 -0
  28. package/dist/lib/lambda-route-proxy-entry-handler.js +72 -0
  29. package/dist/lib/lambda-route-proxy-entry-handler.js.map +1 -0
  30. package/dist/lib/lambda-route-proxy-path-not-found.d.ts +3 -0
  31. package/dist/lib/lambda-route-proxy-path-not-found.d.ts.map +1 -0
  32. package/dist/lib/lambda-route-proxy-path-not-found.js +22 -0
  33. package/dist/lib/lambda-route-proxy-path-not-found.js.map +1 -0
  34. package/dist/lib/middlewares/route-module-jwt-validation-middleware.d.ts +4 -0
  35. package/dist/lib/middlewares/route-module-jwt-validation-middleware.d.ts.map +1 -0
  36. package/dist/lib/middlewares/route-module-jwt-validation-middleware.js +32 -0
  37. package/dist/lib/middlewares/route-module-jwt-validation-middleware.js.map +1 -0
  38. package/dist/lib/middlewares/route-module-schema-validation-middleware.d.ts +4 -0
  39. package/dist/lib/middlewares/route-module-schema-validation-middleware.d.ts.map +1 -0
  40. package/dist/lib/middlewares/route-module-schema-validation-middleware.js +72 -0
  41. package/dist/lib/middlewares/route-module-schema-validation-middleware.js.map +1 -0
  42. package/dist/lib/swagger-route-specification-generator.d.ts +18 -0
  43. package/dist/lib/swagger-route-specification-generator.d.ts.map +1 -0
  44. package/dist/lib/swagger-route-specification-generator.js +115 -0
  45. package/dist/lib/swagger-route-specification-generator.js.map +1 -0
  46. package/dist/lib/swagger-specification-types.d.ts +143 -0
  47. package/dist/lib/swagger-specification-types.d.ts.map +1 -0
  48. package/dist/lib/swagger-specification-types.js +3 -0
  49. package/dist/lib/swagger-specification-types.js.map +1 -0
  50. package/dist/lib/types-and-interfaces.d.ts +78 -0
  51. package/dist/lib/types-and-interfaces.d.ts.map +1 -0
  52. package/dist/lib/types-and-interfaces.js +3 -0
  53. package/dist/lib/types-and-interfaces.js.map +1 -0
  54. package/dist/lib/utils.d.ts +2 -0
  55. package/dist/lib/utils.d.ts.map +1 -0
  56. package/dist/lib/utils.js +17 -0
  57. package/dist/lib/utils.js.map +1 -0
  58. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
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.filter(o=>o.startsWith("--repo=")).map(o=>o.split("=")[1]),n=i.find(o=>o.startsWith("--policy="));c.length===0&&(console.error("Error: at least one --repo argument is required"),console.error("Usage: create-gha-iam-stack --repo=owner/repo-name [--repo=owner/another-repo] [--policy=PolicyName]"),console.error("Example: create-gha-iam-stack --repo=myorg/my-repo --repo=myorg/another-repo --policy=AdministratorAccess"),process.exit(1));var a=c,l=n?n.split("=")[1]:"AdministratorAccess";console.log(`Configuring for repositories: ${a.join(", ")}`);console.log(`Using policy: ${l}`);var p=new t.App,r=class extends t.Stack{constructor(m,g,d){super(m,g,d),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":a.map(h=>`repo:${h}:*`)}}),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)}
2
+ "use strict";var t=require("aws-cdk-lib"),e=require("aws-cdk-lib/aws-iam"),n=require("child_process");console.log("Starting GitHub OIDC IAM setup...");var i=process.argv.slice(2),c=i.filter(o=>o.startsWith("--repo=")).map(o=>o.split("=")[1]),s=i.find(o=>o.startsWith("--policy="));c.length===0&&(console.error("Error: at least one --repo argument is required"),console.error("Usage: create-gha-iam-stack --repo=owner/repo-name [--repo=owner/another-repo] [--policy=PolicyName]"),console.error("Example: create-gha-iam-stack --repo=myorg/my-repo --repo=myorg/another-repo --policy=AdministratorAccess"),process.exit(1));var a=c,l=s?s.split("=")[1]:"AdministratorAccess";console.log(`Configuring for repositories: ${a.join(", ")}`);console.log(`Using policy: ${l}`);var p=new t.App,r=class extends t.Stack{constructor(m,g,d){super(m,g,d),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":a.map(h=>`repo:${h}:*`)}}),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 b=p.synth();console.log("Starting deployment...");try{let o=["cdk deploy","GithubActionsIam","--require-approval never",`--app "${b.directory}"`].join(" ");console.log(`Executing: ${o}`),(0,n.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)}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bootstrap-iam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-iam.d.ts","sourceRoot":"","sources":["../../src/bin/bootstrap-iam.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
4
+ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
5
+ const child_process_1 = require("child_process");
6
+ console.log('Starting GitHub OIDC IAM setup...');
7
+ // Parse command line arguments
8
+ const args = process.argv.slice(2);
9
+ const repoArgs = args.filter(t => t.startsWith("--repo=")).map(t => t.split("=")[1]);
10
+ const policyArg = args.find(t => t.startsWith("--policy="));
11
+ if (repoArgs.length === 0) {
12
+ console.error("Error: at least one --repo argument is required");
13
+ console.error("Usage: create-gha-iam-stack --repo=owner/repo-name [--repo=owner/another-repo] [--policy=PolicyName]");
14
+ console.error("Example: create-gha-iam-stack --repo=myorg/my-repo --repo=myorg/another-repo --policy=AdministratorAccess");
15
+ process.exit(1);
16
+ }
17
+ const repoNames = repoArgs;
18
+ const policyName = policyArg ? policyArg.split("=")[1] : "AdministratorAccess";
19
+ console.log(`Configuring for repositories: ${repoNames.join(", ")}`);
20
+ console.log(`Using policy: ${policyName}`);
21
+ const app = new aws_cdk_lib_1.App();
22
+ class GithubActionsIamStack extends aws_cdk_lib_1.Stack {
23
+ constructor(scope, id, props) {
24
+ super(scope, id, props);
25
+ console.log('Creating OIDC Provider...');
26
+ const githubOidcProvider = new aws_iam_1.CfnOIDCProvider(this, "GithubOidcProvider", {
27
+ url: "https://token.actions.githubusercontent.com",
28
+ clientIdList: ["sts.amazonaws.com"],
29
+ thumbprintList: [
30
+ "6938fd4d98bab03faadb97b34396831e3780aea1",
31
+ "1c58a3a8518e8759bf075b76b750d4f2df264fcd"
32
+ ]
33
+ });
34
+ console.log('Creating IAM Role...');
35
+ const deploymentRole = new aws_iam_1.Role(this, "GithubActionsRole", {
36
+ assumedBy: new aws_iam_1.WebIdentityPrincipal(githubOidcProvider.attrArn, {
37
+ StringEquals: {
38
+ "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
39
+ },
40
+ StringLike: {
41
+ "token.actions.githubusercontent.com:sub": repoNames.map(repo => `repo:${repo}:*`)
42
+ }
43
+ }),
44
+ managedPolicies: [
45
+ aws_iam_1.ManagedPolicy.fromAwsManagedPolicyName(policyName)
46
+ ]
47
+ });
48
+ new aws_cdk_lib_1.CfnOutput(this, "RoleArn", {
49
+ value: deploymentRole.roleArn,
50
+ description: "ARN of role to use in GitHub Actions"
51
+ });
52
+ }
53
+ }
54
+ console.log('Creating CloudFormation stack...');
55
+ new GithubActionsIamStack(app, "GithubActionsIam");
56
+ console.log('Synthesizing CloudFormation template...');
57
+ const assembly = app.synth();
58
+ // Execute the deployment
59
+ console.log('Starting deployment...');
60
+ try {
61
+ const cdkCommand = [
62
+ 'cdk deploy',
63
+ 'GithubActionsIam',
64
+ '--require-approval never',
65
+ `--app "${assembly.directory}"`,
66
+ ].join(' ');
67
+ console.log(`Executing: ${cdkCommand}`);
68
+ (0, child_process_1.execSync)(cdkCommand, {
69
+ stdio: 'inherit',
70
+ env: {
71
+ ...process.env,
72
+ AWS_REGION: process.env.AWS_REGION || 'us-east-1',
73
+ }
74
+ });
75
+ console.log('Deployment completed successfully!');
76
+ }
77
+ catch (error) {
78
+ console.error('Deployment failed:', error);
79
+ process.exit(1);
80
+ }
81
+ //# sourceMappingURL=bootstrap-iam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-iam.js","sourceRoot":"","sources":["../../src/bin/bootstrap-iam.ts"],"names":[],"mappings":";;AAAA,6CAAgE;AAChE,iDAAiG;AACjG,iDAAyC;AAEzC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAEjD,+BAA+B;AAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CA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AAI,WAAW;SAClD;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;CACnD;AAAC,OAAO,KAAK,EAAE;IACd,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ const path_1 = require("path");
5
+ commander_1.program
6
+ .name('aws-lambda-api-tools')
7
+ .description('CLI tools for AWS Lambda and API Gateway')
8
+ .version('0.1.5');
9
+ commander_1.program.command('create-gha-iam-stack')
10
+ .description('Create IAM stack for GitHub Actions OIDC authentication')
11
+ .option('--repo <owner/repo>', 'GitHub repository (owner/repo)', collect, [])
12
+ .option('--policy <name>', 'AWS managed policy name', 'AdministratorAccess')
13
+ .action(async (options) => {
14
+ if (options.repo.length === 0) {
15
+ console.error('Error: at least one --repo argument is required');
16
+ process.exit(1);
17
+ }
18
+ // Convert Commander options to argv format for bootstrap script
19
+ process.argv = [
20
+ process.argv[0],
21
+ process.argv[1],
22
+ ...options.repo.map((repo) => `--repo=${repo}`),
23
+ `--policy=${options.policy}`
24
+ ];
25
+ require((0, path_1.join)(__dirname, 'bootstrap-iam.js'));
26
+ });
27
+ // Helper function to collect multiple --repo options
28
+ function collect(value, previous) {
29
+ return previous.concat([value]);
30
+ }
31
+ commander_1.program.parse();
32
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AACpC,+BAA4B;AAE5B,mBAAO;KACJ,IAAI,CAAC,sBAAsB,CAAC;KAC5B,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,mBAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC;KACpC,WAAW,CAAC,yDAAyD,CAAC;KACtE,MAAM,CAAC,qBAAqB,EAAE,gCAAgC,EAAE,OAAO,EAAE,EAAE,CAAC;KAC5E,MAAM,CAAC,iBAAiB,EAAE,yBAAyB,EAAE,qBAAqB,CAAC;KAC3E,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,gEAAgE;IAChE,OAAO,CAAC,IAAI,GAAG;QACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACf,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC;QACvD,YAAY,OAAO,CAAC,MAAM,EAAE;KAC7B,CAAC;IACF,OAAO,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEL,qDAAqD;AACrD,SAAS,OAAO,CAAC,KAAa,EAAE,QAAkB;IAChD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,mBAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ import { APIGatewayProxyEventV2 } from "aws-lambda";
2
+ export declare const authorizeRoute: (event: APIGatewayProxyEventV2) => void;
3
+ //# sourceMappingURL=authorization-helper.d.ts.map
@@ -0,0 +1 @@
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,yCAO1B,CAAC"}
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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;QACV,qFAAqF;KACtF;IACD,iDAAiD;AACnD,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB"}
@@ -0,0 +1,26 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,148 @@
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 (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.updateCFYamlPropertyInplace = exports.dump = exports.parse = exports.schema = void 0;
41
+ const js_yaml_1 = __importDefault(require("js-yaml"));
42
+ const fs = __importStar(require("fs"));
43
+ const _ = __importStar(require("lodash"));
44
+ /**
45
+ * Split a string on the given separator just once, returning an array of two parts, or null.
46
+ */
47
+ const splitOne = (str, sep) => {
48
+ let index = str.indexOf(sep);
49
+ return index < 0 ? null : [str.slice(0, index), str.slice(index + sep.length)];
50
+ };
51
+ /**
52
+ * Returns true if obj is a representation of a CloudFormation intrinsic, i.e. an object with a
53
+ * single property at key keyName.
54
+ */
55
+ const checkType = (obj, keyName) => {
56
+ return obj && typeof obj === 'object' && Object.keys(obj).length === 1 &&
57
+ obj.hasOwnProperty(keyName);
58
+ };
59
+ const overrides = {
60
+ // ShortHand notation for !GetAtt accepts Resource.Attribute format while the standard notation
61
+ // is to use an array [Resource, Attribute]. Convert shorthand to standard format.
62
+ GetAtt: {
63
+ parse: (data) => typeof data === 'string' ? splitOne(data, '.') : data,
64
+ dump: (data) => data.join('.')
65
+ }
66
+ };
67
+ const applyOverrides = (data, tag, method) => {
68
+ return overrides[tag] ? overrides[tag][method](data) : data;
69
+ };
70
+ /**
71
+ * Generic tag-creating helper. For the given name of the form 'Fn::Something' (or just
72
+ * 'Something'), creates a js-yaml Type object that can parse and dump this type. It creates it
73
+ * for all types of values, for simplicity and because that's how the official Python version
74
+ * works.
75
+ */
76
+ const makeTagTypes = (name) => {
77
+ const parts = splitOne(name, '::');
78
+ const tag = parts ? parts[1] : name;
79
+ // Translate in the same way for all types, to match Python's generic translation.
80
+ return ['scalar', 'sequence', 'mapping'].map((kind) => new js_yaml_1.default.Type('!' + tag, {
81
+ kind: kind,
82
+ construct: (data) => ({ [name]: applyOverrides(data, tag, 'parse') }),
83
+ predicate: (obj) => checkType(obj, name),
84
+ represent: (obj) => applyOverrides(obj[name], tag, 'dump'),
85
+ }));
86
+ };
87
+ /**
88
+ * This list is from
89
+ * http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
90
+ * Note that the Python version handles ANY tag that starts with ! in the same way (translating it
91
+ * to Fn:: prefix, but js-yaml requires listing tags explicitly.
92
+ */
93
+ const supportedFunctions = [
94
+ 'Fn::Base64',
95
+ 'Fn::Cidr',
96
+ 'Fn::FindInMap',
97
+ 'Fn::GetAtt',
98
+ 'Fn::GetAZs',
99
+ 'Fn::ImportValue',
100
+ 'Fn::Join',
101
+ 'Fn::Select',
102
+ 'Fn::Split',
103
+ 'Fn::Sub',
104
+ 'Fn::Transform',
105
+ 'Ref',
106
+ 'Condition',
107
+ 'Fn::And',
108
+ 'Fn::Equals',
109
+ 'Fn::If',
110
+ 'Fn::Not',
111
+ 'Fn::Or',
112
+ ];
113
+ const allTagTypes = [];
114
+ for (let name of supportedFunctions) {
115
+ allTagTypes.push(...makeTagTypes(name));
116
+ }
117
+ /**
118
+ * The actual js-yaml schema, extending the DEFAULT_SAFE_SCHEMA.
119
+ */
120
+ exports.schema = js_yaml_1.default.CORE_SCHEMA.extend({
121
+ implicit: [],
122
+ explicit: allTagTypes,
123
+ });
124
+ /**
125
+ * Convenience function to parse the given yaml input.
126
+ */
127
+ const parse = (input) => js_yaml_1.default.load(input, { schema: exports.schema });
128
+ exports.parse = parse;
129
+ ;
130
+ /**
131
+ * Convenience function to serialize the given object to Yaml.
132
+ */
133
+ const dump = (input) => js_yaml_1.default.dump(input, { schema: exports.schema });
134
+ exports.dump = dump;
135
+ const updateCFYamlPropertyInplace = (pathToYaml, propertyPath, propertyValue) => {
136
+ try {
137
+ const doc = (0, exports.parse)(fs.readFileSync(pathToYaml, 'utf8'));
138
+ // console.log(`${doc}`);
139
+ _.set(doc, propertyPath, propertyValue);
140
+ fs.writeFileSync(pathToYaml, (0, exports.dump)(doc));
141
+ }
142
+ catch (e) {
143
+ console.log('--- ERROR: Could not perform yaml update. ---');
144
+ console.log(JSON.stringify(e));
145
+ }
146
+ };
147
+ exports.updateCFYamlPropertyInplace = updateCFYamlPropertyInplace;
148
+ //# sourceMappingURL=cf-yaml-helper.js.map
@@ -0,0 +1 @@
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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AC,CAAC;QAC5D,yBAAyB;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;KACzC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KAChC;AACH,CAAC,CAAC;AAVW,QAAA,2BAA2B,+BAUtC"}
@@ -0,0 +1,8 @@
1
+ export declare class CustomError extends Error {
2
+ _httpStatusCode: number;
3
+ _message: string;
4
+ constructor(message: string, statusCode: number);
5
+ get httpStatusCode(): number;
6
+ get message(): string;
7
+ }
8
+ //# sourceMappingURL=custom-error.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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;;MAAkD,WAUjI,CAAC;AAEF,eAAO,MAAM,oBAAoB,mBAA0B,WAAW,YAAY,cAAc,KAAG,QAAQ,GAAG,CAM7G,CAAC;AAEF,eAAO,MAAM,4BAA4B,WAAY,WAAW;;oDAgD7D,CAAC"}
@@ -0,0 +1,72 @@
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
@@ -0,0 +1 @@
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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U,EAAE;QACnB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC7D,IAAI,KAAK,YAAY,0BAAW,EAAE;YAChC,MAAM,GAAG;gBACP,UAAU,EAAE,KAAK,CAAC,cAAc;gBAChC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,KAAK,CAAC,OAAO;aACpB,CAAC;SACH;aAAM;YACL,MAAM,GAAG;gBACP,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;SACH;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAhDS,QAAA,4BAA4B,gCAgDrC"}
@@ -0,0 +1,3 @@
1
+ import { RouteModule } from './types-and-interfaces';
2
+ export declare const lambdaRouteProxyPathNotFound: RouteModule;
3
+ //# sourceMappingURL=lambda-route-proxy-path-not-found.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,22 @@
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
@@ -0,0 +1 @@
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;QAC5D,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;KACH;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"}
@@ -0,0 +1,4 @@
1
+ import { RouteArguments } from '../types-and-interfaces';
2
+ export declare const jwtValidationMiddleware: (incomingData: RouteArguments) => RouteArguments;
3
+ export default jwtValidationMiddleware;
4
+ //# sourceMappingURL=route-module-jwt-validation-middleware.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,32 @@
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
@@ -0,0 +1 @@
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;QACf,MAAM,IAAI,0BAAW,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;KACjE;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;QACR,MAAM,IAAI,0BAAW,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;KAChD;IACD,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE;QACvB,MAAM,IAAI,0BAAW,CAAC,+CAA+C,EAAE,GAAG,CAAC,CAAC;KAC7E;IACD,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;QACjC,MAAM,IAAI,0BAAW,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;KACzD;IACD,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,EAAE;QAC9C,MAAM,IAAI,0BAAW,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;KAChD;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"}
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,72 @@
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
@@ -0,0 +1 @@
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,GA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,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE;QAC3E,MAAM,sBAAsB,GAAG;MAC7B,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;MAC/E,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;MACpF,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;KACzE,CAAC;QACF,MAAM,IAAI,0BAAW,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;KACpD;SAAM;QACL,OAAO;YACL,GAAG,eAAe;YAClB,GAAG,IAAI;SACR,CAAC;KACH;AACH,CAAC,CAAC;AAxDW,QAAA,0BAA0B,8BAwDrC;AAEF,kBAAe,kCAA0B,CAAC"}
@@ -0,0 +1,18 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,115 @@
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.generateRouteSwaggerSpec = void 0;
30
+ const joi = __importStar(require("joi"));
31
+ const joi_to_swagger_1 = __importDefault(require("joi-to-swagger"));
32
+ const generateRouteSwaggerSpec = (schema, routeEntry) => {
33
+ const { requestBody: requestBodyJoiSchema, query: queryJoiSchema, params: pathParamsJoiSchema, responseBody: responseBodyJoiSchema } = { requestBody: {}, query: {}, params: {}, responseBody: {}, ...schema };
34
+ const { description, swaggerMethodName } = routeEntry;
35
+ // console.log('schema:')
36
+ // console.log(schema);
37
+ let parameters = [];
38
+ let requestBody = undefined;
39
+ let responseBody = { description: 'Default response' };
40
+ // let requestBodyRefKey: string | undefined;
41
+ // let responseBodyRefKey: string | undefined;
42
+ let componentSchemas = {};
43
+ if (pathParamsJoiSchema && Object.keys(pathParamsJoiSchema).length > 0) {
44
+ const pathParamsKeys = Object.keys(pathParamsJoiSchema);
45
+ const pathParamsSwaggerParameters = pathParamsKeys.map((key) => ({
46
+ name: key,
47
+ in: 'path',
48
+ required: true,
49
+ schema: (0, joi_to_swagger_1.default)(pathParamsJoiSchema[key]).swagger,
50
+ }));
51
+ parameters = Array().concat(parameters, pathParamsSwaggerParameters);
52
+ }
53
+ if (queryJoiSchema && Object.keys(queryJoiSchema).length > 0) {
54
+ const queryKeys = Object.keys(queryJoiSchema);
55
+ const queryParamsSwaggerParameters = queryKeys.map((key) => {
56
+ const { presence } = queryJoiSchema[key]._flags;
57
+ return {
58
+ name: key,
59
+ in: 'query',
60
+ required: presence === 'required',
61
+ schema: (0, joi_to_swagger_1.default)(queryJoiSchema[key]).swagger,
62
+ };
63
+ });
64
+ parameters = Array().concat(parameters, queryParamsSwaggerParameters);
65
+ }
66
+ if (requestBodyJoiSchema && Object.keys(requestBodyJoiSchema).length > 0) {
67
+ const { swagger, components: requestComponent } = (0, joi_to_swagger_1.default)(joi.isSchema(requestBodyJoiSchema) ? requestBodyJoiSchema : joi.object(requestBodyJoiSchema));
68
+ requestBody = {
69
+ description: 'Default response body',
70
+ content: {
71
+ 'application/json': {
72
+ schema: swagger,
73
+ },
74
+ },
75
+ };
76
+ // console.log(swagger);
77
+ if (swagger.$ref || (swagger.items && swagger.items.$ref)) {
78
+ // requestBodyRefKey = swagger.$ref.split('/').reverse()[0];
79
+ componentSchemas = { ...componentSchemas, ...requestComponent.schemas };
80
+ }
81
+ }
82
+ if (responseBodyJoiSchema && Object.keys(responseBodyJoiSchema).length > 0) {
83
+ const { swagger, components: responseComponent } = (0, joi_to_swagger_1.default)(joi.isSchema(responseBodyJoiSchema) ? responseBodyJoiSchema : joi.object(responseBodyJoiSchema));
84
+ // console.log(JSON.stringify(j2s, null, 2));
85
+ // console.log(swagger);
86
+ responseBody = {
87
+ description: 'Default response body',
88
+ content: {
89
+ 'application/json': {
90
+ schema: swagger,
91
+ },
92
+ },
93
+ };
94
+ if (swagger.$ref || (swagger.items && swagger.items.$ref)) {
95
+ // responseBodyRefKey = swagger.$ref.split('/').reverse()[0];
96
+ componentSchemas = { ...componentSchemas, ...responseComponent.schemas };
97
+ }
98
+ }
99
+ return {
100
+ path: {
101
+ description,
102
+ operationId: swaggerMethodName || undefined,
103
+ parameters,
104
+ requestBody,
105
+ responses: {
106
+ '200': responseBody,
107
+ },
108
+ },
109
+ components: {
110
+ schemas: componentSchemas,
111
+ },
112
+ };
113
+ };
114
+ exports.generateRouteSwaggerSpec = generateRouteSwaggerSpec;
115
+ //# sourceMappingURL=swagger-route-specification-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger-route-spec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;YAC5D,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,gBAAiB,CAAC,OAAO,EAAE,CAAC;SAC1E;KACF;IACD,IAAI,qBAAqB,IAAI,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1E,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,IAAA,wBAAY,EAC7D,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAChG,CAAC;QACF,6CAA6C;QAC7C,wBAAwB;QACxB,YAAY,GAAG;YACb,WAAW,EAAE,uBAAuB;YACpC,OAAO,EAAE;gBACP,kBAAkB,EAAE;oBAClB,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;YACzD,6DAA6D;YAC7D,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,iBAAkB,CAAC,OAAO,EAAE,CAAC;SAC3E;KACF;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"}
@@ -0,0 +1,143 @@
1
+ /// <reference types="node" />
2
+ import type { URL } from 'url';
3
+ export interface OpenAPI2 {
4
+ swagger: string;
5
+ paths?: Record<string, PathItemObject>;
6
+ definitions?: Record<string, SchemaObject>;
7
+ parameters?: ParameterObject[];
8
+ responses?: Record<string, ResponseObject>;
9
+ }
10
+ export interface OpenAPI3 {
11
+ openapi: string;
12
+ paths?: Record<string, PathItemObject>;
13
+ components?: {
14
+ schemas?: Record<string, ReferenceObject | SchemaObject>;
15
+ responses?: Record<string, ReferenceObject | ResponseObject>;
16
+ parameters?: Record<string, ReferenceObject | ParameterObject>;
17
+ requestBodies?: Record<string, ReferenceObject | RequestBody>;
18
+ headers?: Record<string, ReferenceObject | HeaderObject>;
19
+ links?: Record<string, ReferenceObject | LinkObject>;
20
+ };
21
+ }
22
+ export interface HeaderObject {
23
+ type?: string;
24
+ description?: string;
25
+ required?: boolean;
26
+ schema: ReferenceObject | SchemaObject;
27
+ }
28
+ export interface PathItemObject {
29
+ $ref?: string;
30
+ summary?: string;
31
+ description?: string;
32
+ get?: OperationObject;
33
+ put?: OperationObject;
34
+ post?: OperationObject;
35
+ delete?: OperationObject;
36
+ options?: OperationObject;
37
+ head?: OperationObject;
38
+ patch?: OperationObject;
39
+ trace?: OperationObject;
40
+ parameters?: (ReferenceObject | ParameterObject)[];
41
+ }
42
+ export interface LinkObject {
43
+ operationRef?: string;
44
+ operationId?: string;
45
+ parameters?: (ReferenceObject | ParameterObject)[];
46
+ requestBody?: RequestBody;
47
+ description?: string;
48
+ }
49
+ export interface OperationObject {
50
+ description?: string;
51
+ tags?: string[];
52
+ summary?: string;
53
+ operationId?: string;
54
+ parameters?: (ReferenceObject | ParameterObject)[];
55
+ requestBody?: ReferenceObject | RequestBody;
56
+ responses?: Record<string, ReferenceObject | ResponseObject>;
57
+ }
58
+ export interface ParameterObject {
59
+ name?: string;
60
+ in?: "query" | "header" | "path" | /* V3 */ "cookie" | /* V2 */ "formData" | /* V2 */ "body";
61
+ description?: string;
62
+ required?: boolean;
63
+ deprecated?: boolean;
64
+ schema?: ReferenceObject | SchemaObject;
65
+ type?: "string" | "number" | "integer" | "boolean" | "array" | "file";
66
+ items?: ReferenceObject | SchemaObject;
67
+ enum?: string[];
68
+ }
69
+ export type ReferenceObject = {
70
+ $ref: string;
71
+ };
72
+ export interface ResponseObject {
73
+ description?: string;
74
+ headers?: Record<string, ReferenceObject | HeaderObject>;
75
+ schema?: ReferenceObject | SchemaObject;
76
+ links?: Record<string, ReferenceObject | LinkObject>;
77
+ content?: {
78
+ [contentType: string]: {
79
+ schema: ReferenceObject | SchemaObject;
80
+ };
81
+ };
82
+ }
83
+ export interface RequestBody {
84
+ description?: string;
85
+ content?: {
86
+ [contentType: string]: {
87
+ schema: ReferenceObject | SchemaObject;
88
+ };
89
+ };
90
+ }
91
+ export interface SchemaObject {
92
+ title?: string;
93
+ description?: string;
94
+ required?: string[];
95
+ enum?: string[];
96
+ type?: string;
97
+ items?: ReferenceObject | SchemaObject;
98
+ allOf?: SchemaObject;
99
+ properties?: Record<string, ReferenceObject | SchemaObject>;
100
+ default?: any;
101
+ additionalProperties?: boolean | ReferenceObject | SchemaObject;
102
+ nullable?: boolean;
103
+ oneOf?: (ReferenceObject | SchemaObject)[];
104
+ anyOf?: (ReferenceObject | SchemaObject)[];
105
+ format?: string;
106
+ }
107
+ export type SchemaFormatter = (schemaObj: SchemaObject) => string | undefined;
108
+ export interface SwaggerToTSOptions {
109
+ /** Allow arbitrary properties on schemas (default: false) */
110
+ additionalProperties?: boolean;
111
+ /** (optional) Specify auth if using openapi-typescript to fetch URL */
112
+ auth?: string;
113
+ /** (optional) Specify current working directory (cwd) to resolve remote schemas on disk (not needed for remote URL schemas) */
114
+ cwd?: URL;
115
+ /** Specify a formatter */
116
+ formatter?: SchemaFormatter;
117
+ /** Generates immutable types (readonly properties and readonly array) */
118
+ immutableTypes?: boolean;
119
+ /** (optional) Treat schema objects with default values as non-nullable */
120
+ defaultNonNullable?: boolean;
121
+ /** (optional) Path to Prettier config */
122
+ prettierConfig?: string;
123
+ /** (optional) Parsing input document as raw schema rather than OpenAPI document */
124
+ rawSchema?: boolean;
125
+ /** (optional) Should logging be suppressed? (necessary for STDOUT) */
126
+ silent?: boolean;
127
+ /** (optional) OpenAPI version. Must be present if parsing raw schema */
128
+ version?: number;
129
+ }
130
+ /** Context passed to all submodules */
131
+ export interface GlobalContext {
132
+ additionalProperties: boolean;
133
+ auth?: string;
134
+ formatter?: SchemaFormatter;
135
+ immutableTypes: boolean;
136
+ defaultNonNullable: boolean;
137
+ /** (optional) Should logging be suppressed? (necessary for STDOUT) */
138
+ silent?: boolean;
139
+ namespace?: string;
140
+ rawSchema: boolean;
141
+ version: number;
142
+ }
143
+ //# sourceMappingURL=swagger-specification-types.d.ts.map
@@ -0,0 +1 @@
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,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,CAAC,CAAC;QACzD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAAC,CAAC;QAC7D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC,CAAC;QAC/D,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC,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EAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=swagger-specification-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger-specification-types.js","sourceRoot":"","sources":["../../src/lib/swagger-specification-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
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
@@ -0,0 +1 @@
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,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IACjF,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;KAAE,CAAC;IACxC,KAAK,CAAC,EAAE;QAAE,CAAC,GA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AC,CAAC,CAAC;IAC5D,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;CAC1B;AAED,MAAM,MAAM,6BAA6B,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,cAAc,CAAC;AACnF,MAAM,MAAM,gCAAgC,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,GAAG,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"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types-and-interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-and-interfaces.js","sourceRoot":"","sources":["../../src/lib/types-and-interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const parseJwt: (token: string) => any;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,UAAW,MAAM,QAQrC,CAAC"}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-lambda-api-tools",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {