@xube/kit-aws-auth-infrastructure 0.0.62
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/dist/api/auth-api.d.ts +12 -0
- package/dist/api/auth-api.js +24 -0
- package/dist/api/login.d.ts +11 -0
- package/dist/api/login.js +23 -0
- package/dist/api/signup.d.ts +11 -0
- package/dist/api/signup.js +23 -0
- package/dist/auth-management.d.ts +20 -0
- package/dist/auth-management.js +48 -0
- package/dist/functions/login.d.ts +1 -0
- package/dist/functions/login.js +2 -0
- package/dist/functions/pre-signup.d.ts +2 -0
- package/dist/functions/pre-signup.js +17 -0
- package/dist/functions/signup.d.ts +0 -0
- package/dist/functions/signup.js +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -0
- package/package.json +32 -0
- package/src/api/auth-api.ts +42 -0
- package/src/api/login.ts +35 -0
- package/src/api/signup.ts +35 -0
- package/src/auth-management.ts +70 -0
- package/src/functions/login.ts +2 -0
- package/src/functions/pre-signup.ts +24 -0
- package/src/functions/signup.ts +0 -0
- package/src/index.ts +0 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { XubeRestAPI, XubeRestAPIProps } from "@xube/kit-aws-infrastructure";
|
|
2
|
+
import { IUserPool } from "aws-cdk-lib/aws-cognito";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
export declare const AUTH_PATH = "auth";
|
|
5
|
+
interface AuthAPIProps extends XubeRestAPIProps {
|
|
6
|
+
userPool: IUserPool;
|
|
7
|
+
}
|
|
8
|
+
export declare class AuthAPIManager extends Construct {
|
|
9
|
+
authApi: XubeRestAPI;
|
|
10
|
+
constructor(scope: Construct, id: string, props: AuthAPIProps);
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthAPIManager = exports.AUTH_PATH = void 0;
|
|
4
|
+
const kit_aws_infrastructure_1 = require("@xube/kit-aws-infrastructure");
|
|
5
|
+
const constructs_1 = require("constructs");
|
|
6
|
+
const login_1 = require("./login");
|
|
7
|
+
const signup_1 = require("./signup");
|
|
8
|
+
exports.AUTH_PATH = "auth";
|
|
9
|
+
class AuthAPIManager extends constructs_1.Construct {
|
|
10
|
+
authApi;
|
|
11
|
+
constructor(scope, id, props) {
|
|
12
|
+
super(scope, id);
|
|
13
|
+
this.authApi = new kit_aws_infrastructure_1.XubeRestAPI(scope, id + "xube-api", props);
|
|
14
|
+
const userSignUp = new signup_1.SignUpAPI(this, id + '-signup-api', {
|
|
15
|
+
name: props.name + '-signup',
|
|
16
|
+
authAPI: this.authApi
|
|
17
|
+
});
|
|
18
|
+
const userLogIn = new login_1.LoginAPI(this, id + '-login-api', {
|
|
19
|
+
name: props.name + '-login',
|
|
20
|
+
authAPI: this.authApi
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AuthAPIManager = AuthAPIManager;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { XubeRestAPI } from "@xube/kit-aws-infrastructure";
|
|
2
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
export interface LoginAPIProps {
|
|
5
|
+
authAPI: XubeRestAPI;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class LoginAPI extends Construct {
|
|
9
|
+
loginFunction: NodejsFunction;
|
|
10
|
+
constructor(scope: Construct, id: string, props: LoginAPIProps);
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoginAPI = void 0;
|
|
4
|
+
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
5
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
6
|
+
const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
7
|
+
const constructs_1 = require("constructs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
class LoginAPI extends constructs_1.Construct {
|
|
10
|
+
loginFunction;
|
|
11
|
+
constructor(scope, id, props) {
|
|
12
|
+
super(scope, id);
|
|
13
|
+
this.loginFunction = new aws_lambda_nodejs_1.NodejsFunction(scope, id + "-login", {
|
|
14
|
+
entry: (0, path_1.join)(__dirname, "../functions/login.ts"),
|
|
15
|
+
runtime: aws_lambda_1.Runtime.NODEJS_18_X,
|
|
16
|
+
functionName: props.name,
|
|
17
|
+
});
|
|
18
|
+
props.authAPI.restAPI.root
|
|
19
|
+
.addResource("/login")
|
|
20
|
+
.addMethod(aws_lambda_1.HttpMethod.POST, new aws_apigateway_1.LambdaIntegration(this.loginFunction));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.LoginAPI = LoginAPI;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { XubeRestAPI } from "@xube/kit-aws-infrastructure";
|
|
2
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
export interface SignUpAPIProps {
|
|
5
|
+
authAPI: XubeRestAPI;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class SignUpAPI extends Construct {
|
|
9
|
+
signupFunction: NodejsFunction;
|
|
10
|
+
constructor(scope: Construct, id: string, props: SignUpAPIProps);
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignUpAPI = void 0;
|
|
4
|
+
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
5
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
6
|
+
const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
7
|
+
const constructs_1 = require("constructs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
class SignUpAPI extends constructs_1.Construct {
|
|
10
|
+
signupFunction;
|
|
11
|
+
constructor(scope, id, props) {
|
|
12
|
+
super(scope, id);
|
|
13
|
+
this.signupFunction = new aws_lambda_nodejs_1.NodejsFunction(scope, id + "-signup", {
|
|
14
|
+
entry: (0, path_1.join)(__dirname, "../functions/signup.ts"),
|
|
15
|
+
runtime: aws_lambda_1.Runtime.NODEJS_18_X,
|
|
16
|
+
functionName: props.name,
|
|
17
|
+
});
|
|
18
|
+
props.authAPI.restAPI.root
|
|
19
|
+
.addResource("/signup")
|
|
20
|
+
.addMethod(aws_lambda_1.HttpMethod.POST, new aws_apigateway_1.LambdaIntegration(this.signupFunction));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.SignUpAPI = SignUpAPI;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { AuthAPIManager } from "./api/auth-api";
|
|
3
|
+
import { XubeUserPool } from "@xube/kit-aws-infrastructure";
|
|
4
|
+
import { PasswordPolicy, UserPoolClient } from "aws-cdk-lib/aws-cognito";
|
|
5
|
+
export interface AuthManagementProps {
|
|
6
|
+
name: string;
|
|
7
|
+
passwordPolicy: PasswordPolicy;
|
|
8
|
+
autoVerify?: {
|
|
9
|
+
email: boolean;
|
|
10
|
+
};
|
|
11
|
+
verification: {
|
|
12
|
+
emailSubject: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class AuthManagement extends Construct {
|
|
16
|
+
userPool: XubeUserPool;
|
|
17
|
+
userPoolClient: UserPoolClient;
|
|
18
|
+
authAPIManager: AuthAPIManager;
|
|
19
|
+
constructor(scope: Construct, id: string, props: AuthManagementProps);
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthManagement = void 0;
|
|
4
|
+
const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
5
|
+
const constructs_1 = require("constructs");
|
|
6
|
+
const auth_api_1 = require("./api/auth-api");
|
|
7
|
+
const kit_aws_infrastructure_1 = require("@xube/kit-aws-infrastructure");
|
|
8
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
11
|
+
const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
|
|
12
|
+
const kit_aws_auth_1 = require("@xube/kit-aws-auth");
|
|
13
|
+
class AuthManagement extends constructs_1.Construct {
|
|
14
|
+
userPool;
|
|
15
|
+
userPoolClient;
|
|
16
|
+
authAPIManager;
|
|
17
|
+
constructor(scope, id, props) {
|
|
18
|
+
super(scope, id);
|
|
19
|
+
const presignup = new aws_lambda_nodejs_1.NodejsFunction(scope, id + "-pre-signup", {
|
|
20
|
+
entry: (0, path_1.join)(__dirname, "functions/pre-signup.ts"),
|
|
21
|
+
runtime: aws_lambda_1.Runtime.NODEJS_18_X,
|
|
22
|
+
functionName: props.name + "-pre-signup",
|
|
23
|
+
});
|
|
24
|
+
this.userPool = new kit_aws_infrastructure_1.XubeUserPool(scope, id + "-xube-pool", {
|
|
25
|
+
name: props.name + "-pool",
|
|
26
|
+
passwordPolicy: props.passwordPolicy,
|
|
27
|
+
autoVerify: props.autoVerify,
|
|
28
|
+
verification: props.verification,
|
|
29
|
+
presignup,
|
|
30
|
+
});
|
|
31
|
+
const userPoolClientName = props.name + "-client";
|
|
32
|
+
this.userPoolClient = this.userPool.userPool.addClient(id + "-client", {
|
|
33
|
+
userPoolClientName,
|
|
34
|
+
authFlows: {
|
|
35
|
+
userPassword: true,
|
|
36
|
+
},
|
|
37
|
+
idTokenValidity: aws_cdk_lib_1.Duration.days(1),
|
|
38
|
+
});
|
|
39
|
+
const clientIdParam = new aws_ssm_1.StringParameter(this, id + "-client-id-param", {
|
|
40
|
+
parameterName: kit_aws_auth_1.DEFAULT_USER_POOL_CLIENT_ID_NAME,
|
|
41
|
+
stringValue: this.userPoolClient.userPoolClientId,
|
|
42
|
+
});
|
|
43
|
+
this.authAPIManager = new auth_api_1.AuthAPIManager(scope, id + "-auth-mgr", {
|
|
44
|
+
userPool: this.userPool.userPool,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.AuthManagement = AuthManagement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = void 0;
|
|
4
|
+
const kit_log_1 = require("@xube/kit-log");
|
|
5
|
+
const handler = async (event, context, callback) => {
|
|
6
|
+
const log = kit_log_1.XubeLog.getInstance();
|
|
7
|
+
if (!event.request.userAttributes.email) {
|
|
8
|
+
log.error("Email not found");
|
|
9
|
+
return callback(new Error("Email not found"), event);
|
|
10
|
+
}
|
|
11
|
+
event.response.autoVerifyEmail = false;
|
|
12
|
+
event.response.autoVerifyPhone = false;
|
|
13
|
+
event.response.autoConfirmUser = true;
|
|
14
|
+
log.info("Accepting user creation");
|
|
15
|
+
return callback(null, event);
|
|
16
|
+
};
|
|
17
|
+
exports.handler = handler;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/index.d.ts
ADDED
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xube/kit-aws-auth-infrastructure",
|
|
3
|
+
"version": "0.0.62",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+ssh://git@github.com/XubeLtd/dev-kit.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "Xube Pty Ltd",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/XubeLtd/dev-kit/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/XubeLtd/dev-kit#readme",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@xube/kit-build": "^0.0.62"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@xube/kit-aws": "^0.0.62",
|
|
24
|
+
"@xube/kit-aws-hooks": "^0.0.62",
|
|
25
|
+
"@xube/kit-aws-infrastructure": "^0.0.62",
|
|
26
|
+
"@xube/kit-constants": "^0.0.62",
|
|
27
|
+
"@xube/kit-log": "^0.0.62",
|
|
28
|
+
"aws-cdk-lib": "^2.100.0",
|
|
29
|
+
"aws-lambda": "^1.0.7",
|
|
30
|
+
"constructs": "^10.3.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { XubeRestAPI, XubeRestAPIProps } from "@xube/kit-aws-infrastructure";
|
|
2
|
+
import { CorsOptions, IAuthorizer, IDomainName, RestApi } from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
4
|
+
import { IUserPool } from "aws-cdk-lib/aws-cognito";
|
|
5
|
+
import { Construct } from "constructs";
|
|
6
|
+
import { LoginAPI } from "./login";
|
|
7
|
+
import { SignUpAPI } from "./signup";
|
|
8
|
+
|
|
9
|
+
export const AUTH_PATH = "auth";
|
|
10
|
+
|
|
11
|
+
interface AuthAPIProps extends XubeRestAPIProps {
|
|
12
|
+
userPool: IUserPool;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class AuthAPIManager extends Construct {
|
|
16
|
+
authApi: XubeRestAPI;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
scope: Construct,
|
|
20
|
+
id: string,
|
|
21
|
+
props: AuthAPIProps
|
|
22
|
+
) {
|
|
23
|
+
super(scope, id);
|
|
24
|
+
|
|
25
|
+
this.authApi = new XubeRestAPI(scope, id + "xube-api", props);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const userSignUp = new SignUpAPI(this, id + '-signup-api', {
|
|
29
|
+
name: props.name + '-signup',
|
|
30
|
+
authAPI: this.authApi
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const userLogIn = new LoginAPI(
|
|
34
|
+
this,
|
|
35
|
+
id + '-login-api',
|
|
36
|
+
{
|
|
37
|
+
name: props.name + '-login',
|
|
38
|
+
authAPI: this.authApi
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/api/login.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { XubeRestAPI } from "@xube/kit-aws-infrastructure";
|
|
2
|
+
import {
|
|
3
|
+
LambdaIntegration,
|
|
4
|
+
} from "aws-cdk-lib/aws-apigateway";
|
|
5
|
+
import { HttpMethod, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
6
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
7
|
+
import { Construct } from "constructs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
|
|
10
|
+
export interface LoginAPIProps {
|
|
11
|
+
authAPI: XubeRestAPI;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class LoginAPI extends Construct {
|
|
16
|
+
loginFunction: NodejsFunction;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
scope: Construct,
|
|
20
|
+
id: string,
|
|
21
|
+
props: LoginAPIProps
|
|
22
|
+
) {
|
|
23
|
+
super(scope, id);
|
|
24
|
+
|
|
25
|
+
this.loginFunction = new NodejsFunction(scope, id + "-login", {
|
|
26
|
+
entry: join(__dirname, "../functions/login.ts"),
|
|
27
|
+
runtime: Runtime.NODEJS_18_X,
|
|
28
|
+
functionName: props.name,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
props.authAPI.restAPI.root
|
|
32
|
+
.addResource("/login")
|
|
33
|
+
.addMethod(HttpMethod.POST, new LambdaIntegration(this.loginFunction));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { XubeRestAPI } from "@xube/kit-aws-infrastructure";
|
|
2
|
+
import {
|
|
3
|
+
LambdaIntegration,
|
|
4
|
+
} from "aws-cdk-lib/aws-apigateway";
|
|
5
|
+
import { HttpMethod, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
6
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
7
|
+
import { Construct } from "constructs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
|
|
10
|
+
export interface SignUpAPIProps {
|
|
11
|
+
authAPI: XubeRestAPI;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class SignUpAPI extends Construct {
|
|
16
|
+
signupFunction: NodejsFunction;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
scope: Construct,
|
|
20
|
+
id: string,
|
|
21
|
+
props: SignUpAPIProps
|
|
22
|
+
) {
|
|
23
|
+
super(scope, id);
|
|
24
|
+
|
|
25
|
+
this.signupFunction = new NodejsFunction(scope, id + "-signup", {
|
|
26
|
+
entry: join(__dirname, "../functions/signup.ts"),
|
|
27
|
+
runtime: Runtime.NODEJS_18_X,
|
|
28
|
+
functionName: props.name,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
props.authAPI.restAPI.root
|
|
32
|
+
.addResource("/signup")
|
|
33
|
+
.addMethod(HttpMethod.POST, new LambdaIntegration(this.signupFunction));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { LoginAPI } from "./api/login";
|
|
4
|
+
import { SignUpAPI } from "./api/signup";
|
|
5
|
+
import { AuthAPIManager } from "./api/auth-api";
|
|
6
|
+
import { XubeUserPool } from "@xube/kit-aws-infrastructure";
|
|
7
|
+
import { PasswordPolicy, UserPoolClient } from "aws-cdk-lib/aws-cognito";
|
|
8
|
+
import { Runtime } from "aws-cdk-lib/aws-lambda";
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
import { Duration } from "aws-cdk-lib";
|
|
11
|
+
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
12
|
+
import { DEFAULT_USER_POOL_CLIENT_ID_NAME } from "@xube/kit-aws-auth";
|
|
13
|
+
|
|
14
|
+
export interface AuthManagementProps {
|
|
15
|
+
name: string;
|
|
16
|
+
passwordPolicy: PasswordPolicy;
|
|
17
|
+
autoVerify?: {
|
|
18
|
+
email: boolean;
|
|
19
|
+
};
|
|
20
|
+
verification: {
|
|
21
|
+
emailSubject: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class AuthManagement extends Construct {
|
|
26
|
+
userPool: XubeUserPool;
|
|
27
|
+
userPoolClient: UserPoolClient;
|
|
28
|
+
authAPIManager: AuthAPIManager;
|
|
29
|
+
|
|
30
|
+
constructor(scope: Construct, id: string, props: AuthManagementProps) {
|
|
31
|
+
super(scope, id);
|
|
32
|
+
|
|
33
|
+
const presignup: NodejsFunction = new NodejsFunction(
|
|
34
|
+
scope,
|
|
35
|
+
id + "-pre-signup",
|
|
36
|
+
{
|
|
37
|
+
entry: join(__dirname, "functions/pre-signup.ts"),
|
|
38
|
+
runtime: Runtime.NODEJS_18_X,
|
|
39
|
+
functionName: props.name + "-pre-signup",
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
this.userPool = new XubeUserPool(scope, id + "-xube-pool", {
|
|
44
|
+
name: props.name + "-pool",
|
|
45
|
+
passwordPolicy: props.passwordPolicy,
|
|
46
|
+
autoVerify: props.autoVerify,
|
|
47
|
+
verification: props.verification,
|
|
48
|
+
presignup,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const userPoolClientName = props.name + "-client";
|
|
52
|
+
|
|
53
|
+
this.userPoolClient = this.userPool.userPool.addClient(id + "-client", {
|
|
54
|
+
userPoolClientName,
|
|
55
|
+
authFlows: {
|
|
56
|
+
userPassword: true,
|
|
57
|
+
},
|
|
58
|
+
idTokenValidity: Duration.days(1),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const clientIdParam = new StringParameter(this, id + "-client-id-param", {
|
|
62
|
+
parameterName: DEFAULT_USER_POOL_CLIENT_ID_NAME,
|
|
63
|
+
stringValue: this.userPoolClient.userPoolClientId,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
this.authAPIManager = new AuthAPIManager(scope, id + "-auth-mgr", {
|
|
67
|
+
userPool: this.userPool.userPool,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { XubeLog } from "@xube/kit-log";
|
|
2
|
+
import { Context, PreSignUpTriggerEvent } from "aws-lambda";
|
|
3
|
+
|
|
4
|
+
export const handler = async (
|
|
5
|
+
event: PreSignUpTriggerEvent,
|
|
6
|
+
context: Context,
|
|
7
|
+
callback: (err: any, data: PreSignUpTriggerEvent) => any
|
|
8
|
+
) => {
|
|
9
|
+
const log = XubeLog.getInstance();
|
|
10
|
+
|
|
11
|
+
if (!event.request.userAttributes.email) {
|
|
12
|
+
log.error("Email not found");
|
|
13
|
+
return callback(new Error("Email not found"), event);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
event.response.autoVerifyEmail = false;
|
|
17
|
+
event.response.autoVerifyPhone = false;
|
|
18
|
+
event.response.autoConfirmUser = true;
|
|
19
|
+
|
|
20
|
+
log.info("Accepting user creation");
|
|
21
|
+
|
|
22
|
+
return callback(null, event);
|
|
23
|
+
};
|
|
24
|
+
|
|
File without changes
|
package/src/index.ts
ADDED
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../kit-build/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist"
|
|
6
|
+
},
|
|
7
|
+
"exclude": ["**/*.test.ts", "**/*.mock.ts", "dist"],
|
|
8
|
+
"references": [
|
|
9
|
+
{
|
|
10
|
+
"path": "../kit-constants"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"path": "../kit-log"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "../kit-aws"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "../kit-aws-auth"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "../kit-aws-infrastructure"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
|