@xube/kit-aws-auth-infrastructure 0.0.63 → 0.0.64

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.
@@ -1 +1,2 @@
1
- export {};
1
+ import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda";
2
+ export declare const handler: (event: APIGatewayProxyEvent, context: Context) => Promise<APIGatewayProxyResult>;
@@ -1,2 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const kit_constants_1 = require("@xube/kit-constants");
5
+ const kit_aws_auth_1 = require("@xube/kit-aws-auth");
6
+ const kit_aws_auth_2 = require("@xube/kit-aws-auth");
7
+ const kit_log_1 = require("@xube/kit-log");
8
+ const handler = async (event, context) => {
9
+ const log = kit_log_1.XubeLog.getInstance();
10
+ if (!event.body) {
11
+ return {
12
+ statusCode: kit_constants_1.StatusCode.BadRequest,
13
+ body: "No body found",
14
+ };
15
+ }
16
+ try {
17
+ const body = JSON.parse(event.body);
18
+ if (!(0, kit_aws_auth_1.isLoginRequest)(body)) {
19
+ return {
20
+ statusCode: kit_constants_1.StatusCode.BadRequest,
21
+ body: "Invalid login request",
22
+ };
23
+ }
24
+ const loginResponse = await (0, kit_aws_auth_2.logIn)(body);
25
+ if (loginResponse.hasFailed()) {
26
+ log.info(`Login failed: ${JSON.stringify(loginResponse)}`);
27
+ }
28
+ return {
29
+ statusCode: loginResponse.statusCode,
30
+ body: JSON.stringify(loginResponse.data) ??
31
+ loginResponse.error ??
32
+ `Could not complete login request`,
33
+ };
34
+ }
35
+ catch (error) {
36
+ return {
37
+ statusCode: kit_constants_1.StatusCode.InternalError,
38
+ body: "An internal error occurred when logging in.",
39
+ };
40
+ }
41
+ };
42
+ exports.handler = handler;
@@ -0,0 +1,2 @@
1
+ import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda";
2
+ export declare const handler: (event: APIGatewayProxyEvent, context: Context) => Promise<APIGatewayProxyResult>;
@@ -1 +1,41 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const kit_aws_auth_1 = require("@xube/kit-aws-auth");
5
+ const kit_constants_1 = require("@xube/kit-constants");
6
+ const kit_log_1 = require("@xube/kit-log");
7
+ const handler = async (event, context) => {
8
+ const log = kit_log_1.XubeLog.getInstance();
9
+ if (!event.body) {
10
+ return {
11
+ statusCode: kit_constants_1.StatusCode.BadRequest,
12
+ body: "No body found",
13
+ };
14
+ }
15
+ try {
16
+ const body = JSON.parse(event.body);
17
+ if (!(0, kit_aws_auth_1.isSignupRequest)(body)) {
18
+ return {
19
+ statusCode: kit_constants_1.StatusCode.BadRequest,
20
+ body: "Invalid signup request",
21
+ };
22
+ }
23
+ const createUserResponse = await (0, kit_aws_auth_1.createUser)(body, log);
24
+ if (createUserResponse.hasFailed()) {
25
+ log.info(`Signup failed: ${JSON.stringify(createUserResponse)}`);
26
+ }
27
+ return {
28
+ statusCode: createUserResponse.statusCode,
29
+ body: JSON.stringify(createUserResponse.data) ??
30
+ createUserResponse.error ??
31
+ `Could not complete signup request`,
32
+ };
33
+ }
34
+ catch (error) {
35
+ return {
36
+ statusCode: kit_constants_1.StatusCode.InternalError,
37
+ body: "An internal error occurred when signing up in.",
38
+ };
39
+ }
40
+ };
41
+ exports.handler = handler;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- export * from "./auth-management";
2
1
  export * from "./api/auth-api";
2
+ export * from "./api/login";
3
+ export * from "./api/signup";
4
+ export * from "./auth-management";
package/dist/index.js CHANGED
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./auth-management"), exports);
18
17
  __exportStar(require("./api/auth-api"), exports);
18
+ __exportStar(require("./api/login"), exports);
19
+ __exportStar(require("./api/signup"), exports);
20
+ __exportStar(require("./auth-management"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-auth-infrastructure",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,14 +17,15 @@
17
17
  },
18
18
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
19
19
  "devDependencies": {
20
- "@xube/kit-build": "^0.0.63"
20
+ "@xube/kit-build": "^0.0.64"
21
21
  },
22
22
  "dependencies": {
23
- "@xube/kit-aws": "^0.0.63",
24
- "@xube/kit-aws-hooks": "^0.0.63",
25
- "@xube/kit-aws-infrastructure": "^0.0.63",
26
- "@xube/kit-constants": "^0.0.63",
27
- "@xube/kit-log": "^0.0.63",
23
+ "@xube/kit-aws": "^0.0.64",
24
+ "@xube/kit-aws-auth": "^0.0.64",
25
+ "@xube/kit-aws-hooks": "^0.0.64",
26
+ "@xube/kit-aws-infrastructure": "^0.0.64",
27
+ "@xube/kit-constants": "^0.0.64",
28
+ "@xube/kit-log": "^0.0.64",
28
29
  "aws-cdk-lib": "^2.100.0",
29
30
  "aws-lambda": "^1.0.7",
30
31
  "constructs": "^10.3.0"
@@ -1,2 +1,52 @@
1
1
  import { StatusCode } from "@xube/kit-constants";
2
2
  import { XubeResponse } from "../../../kit-request/src";
3
+ import {
4
+ APIGatewayProxyEvent,
5
+ APIGatewayProxyResult,
6
+ Context,
7
+ } from "aws-lambda";
8
+ import { isLoginRequest } from "@xube/kit-aws-auth";
9
+ import { logIn } from "@xube/kit-aws-auth";
10
+ import { XubeLog } from "@xube/kit-log";
11
+
12
+ export const handler = async (
13
+ event: APIGatewayProxyEvent,
14
+ context: Context
15
+ ): Promise<APIGatewayProxyResult> => {
16
+ const log = XubeLog.getInstance();
17
+ if (!event.body) {
18
+ return {
19
+ statusCode: StatusCode.BadRequest,
20
+ body: "No body found",
21
+ };
22
+ }
23
+
24
+ try {
25
+ const body = JSON.parse(event.body);
26
+
27
+ if (!isLoginRequest(body)) {
28
+ return {
29
+ statusCode: StatusCode.BadRequest,
30
+ body: "Invalid login request",
31
+ };
32
+ }
33
+
34
+ const loginResponse = await logIn(body);
35
+
36
+ if (loginResponse.hasFailed()) {
37
+ log.info(`Login failed: ${JSON.stringify(loginResponse)}`);
38
+ }
39
+ return {
40
+ statusCode: loginResponse.statusCode,
41
+ body:
42
+ JSON.stringify(loginResponse.data) ??
43
+ loginResponse.error ??
44
+ `Could not complete login request`,
45
+ };
46
+ } catch (error) {
47
+ return {
48
+ statusCode: StatusCode.InternalError,
49
+ body: "An internal error occurred when logging in.",
50
+ };
51
+ }
52
+ };
@@ -0,0 +1,52 @@
1
+ import { createUser, isSignupRequest } from "@xube/kit-aws-auth";
2
+ import { StatusCode } from "@xube/kit-constants";
3
+ import { XubeLog } from "@xube/kit-log";
4
+ import {
5
+ APIGatewayProxyEvent,
6
+ APIGatewayProxyResult,
7
+ Context,
8
+ } from "aws-lambda";
9
+
10
+ export const handler = async (
11
+ event: APIGatewayProxyEvent,
12
+ context: Context
13
+ ): Promise<APIGatewayProxyResult> => {
14
+ const log = XubeLog.getInstance();
15
+
16
+ if (!event.body) {
17
+ return {
18
+ statusCode: StatusCode.BadRequest,
19
+ body: "No body found",
20
+ };
21
+ }
22
+
23
+ try {
24
+ const body = JSON.parse(event.body);
25
+
26
+ if (!isSignupRequest(body)) {
27
+ return {
28
+ statusCode: StatusCode.BadRequest,
29
+ body: "Invalid signup request",
30
+ };
31
+ }
32
+
33
+ const createUserResponse = await createUser(body, log);
34
+
35
+ if (createUserResponse.hasFailed()) {
36
+ log.info(`Signup failed: ${JSON.stringify(createUserResponse)}`);
37
+ }
38
+
39
+ return {
40
+ statusCode: createUserResponse.statusCode,
41
+ body:
42
+ JSON.stringify(createUserResponse.data) ??
43
+ createUserResponse.error ??
44
+ `Could not complete signup request`,
45
+ };
46
+ } catch (error) {
47
+ return {
48
+ statusCode: StatusCode.InternalError,
49
+ body: "An internal error occurred when signing up in.",
50
+ };
51
+ }
52
+ };
package/src/index.ts CHANGED
@@ -1,2 +1,4 @@
1
- export * from "./auth-management";
2
- export * from "./api/auth-api";
1
+ export * from "./api/auth-api";
2
+ export * from "./api/login";
3
+ export * from "./api/signup";
4
+ export * from "./auth-management";