import { aws_cognito } from "aws-cdk-lib"; import lambda from "aws-lambda"; import { Construct } from "constructs"; import { Function } from "./function"; export declare type Trigger = Function; /** * Triggers for a user pool * @see https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html */ export interface UserPoolTriggers { /** * Creates an authentication challenge. * * ```ts * new UserPool(scope, id, { * createAuthChallenge: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * } * } * ``` * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html * @default - no trigger configured */ readonly createAuthChallenge?: Trigger; /** * A custom Message AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * customMessage: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html * @default - no trigger configured */ readonly customMessage?: Trigger; /** * Defines the authentication challenge. * * ```ts * new UserPool(scope, id, { * defineAuthChallenge: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html * @default - no trigger configured */ readonly defineAuthChallenge?: Trigger; /** * A post-authentication AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * postAuthentication: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-authentication.html * @default - no trigger configured */ readonly postAuthentication?: Trigger; /** * A post-confirmation AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * postConfirmation: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html * @default - no trigger configured */ readonly postConfirmation?: Trigger; /** * A pre-authentication AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * preAuthentication: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-authentication.html * @default - no trigger configured */ readonly preAuthentication?: Trigger; /** * A pre-registration AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * preSignUp: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html * @default - no trigger configured */ readonly preSignUp?: Trigger; /** * A pre-token-generation AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * preTokenGeneration: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html * @default - no trigger configured */ readonly preTokenGeneration?: Trigger; /** * A user-migration AWS Lambda trigger. * * ```ts * new UserPool(scope, id, { * userMigration: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-migrate-user.html * @default - no trigger configured */ readonly userMigration?: Trigger; /** * Verifies the authentication challenge response. * * ```ts * new UserPool(scope, id, { * verifyAuthChallengeResponse: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html * @default - no trigger configured */ readonly verifyAuthChallengeResponse?: Trigger; /** * Amazon Cognito invokes this trigger to send email notifications to users. * * ```ts * new UserPool(scope, id, { * customEmailSender: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-email-sender.html * @default - no trigger configured */ readonly customEmailSender?: Trigger; /** * Amazon Cognito invokes this trigger to send SMS notifications to users. * * ```ts * new UserPool(scope, id, { * customSmsSender: new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * }) * }); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-sms-sender.html * @default - no trigger configured */ readonly customSmsSender?: Trigger; } export interface UserPoolProps extends Omit { /** * Lambda functions to use for supported Cognito triggers. * @see https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html * @default - No Lambda triggers. */ readonly lambdaTriggers?: UserPoolTriggers; } declare class BaseUserPool { /** * The underlying {@link aws_cognito.UserPool} instance. */ readonly resource: aws_cognito.UserPool; static readonly FunctionlessType = "UserPool"; readonly FunctionlessType = "UserPool"; /** * Create a new {@link UserPool} from an existing {@link aws_cognito.UserPool}. * * * @param resource an existing UserPool Construct. * @see {@link aws_cognito.UserPool} */ constructor( /** * The underlying {@link aws_cognito.UserPool} instance. */ resource: aws_cognito.UserPool); /** * Configure AWS Cognito to trigger a {@link Function}. * * Usage Pattern 1 - on("triggerName") * ```ts * userPool.on("createAuthChallenge", new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })) * ``` * * Usage Pattern 2 - {@link aws_cognito.UserPoolTriggers}. * * ```ts * userPool.on( * aws_cognito.UserPoolOperation.CREATE_AUTH_CHALLENGE, * new Function(scope, id, async (event: CreateAuthChallengeTriggerEvent) => { * // ^ you must explicitly type the even in this case * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @param triggerName name of a trigger in {@link UserPoolTriggers} * @param handler the {@link Function} to send the trigger events to. */ on(triggerName: TriggerName, handler: TriggerName extends keyof UserPoolTriggers ? Exclude : Exclude): void; /** * Creates an authentication challenge. * * ```ts * userPool.onCreateAuthChallenge(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html * @default - no trigger configured */ onCreateAuthChallenge(handler: Trigger): void; /** * Amazon Cognito invokes this trigger to send email notifications to users. * * ```ts * userPool.onCustomEmailSender(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-email-sender.html * @default - no trigger configured */ onCustomEmailSender(handler: Trigger): void; /** * A custom Message AWS Lambda trigger. * * ```ts * userPool.onCustomMessage(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html * @default - no trigger configured */ onCustomMessage(handler: Trigger): void; /** * Amazon Cognito invokes this trigger to send SMS notifications to users. * * ```ts * userPool.onCustomMessage(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-sms-sender.html * @default - no trigger configured */ onCustomSmsSender(handler: Trigger): void; /** * Defines the authentication challenge. * * ```ts * userPool.onDefineAuthChallenge(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html * @default - no trigger configured */ onDefineAuthChallenge(handler: Trigger): void; /** * A post-authentication AWS Lambda trigger. * * ```ts * userPool.onPostAuthentication(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-authentication.html * @default - no trigger configured */ onPostAuthentication(handler: Trigger): void; /** * A post-confirmation AWS Lambda trigger. * * ```ts * userPool.onPostConfirmation(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html * @default - no trigger configured */ onPostConfirmation(handler: Trigger): void; /** * A pre-authentication AWS Lambda trigger. * * ```ts * userPool.onPreAuthentication(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-authentication.html * @default - no trigger configured */ onPreAuthentication(handler: Trigger): void; /** * A pre-registration AWS Lambda trigger. * * ```ts * userPool.onPreSignUp(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html * @default - no trigger configured */ onPreSignUp(handler: Trigger): void; /** * A pre-token-generation AWS Lambda trigger. * * ```ts * userPool.onPreTokenGeneration(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html * @default - no trigger configured */ onPreTokenGeneration(handler: Trigger): void; /** * A user-migration AWS Lambda trigger. * * ```ts * userPool.onUserMigration(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-migrate-user.html * @default - no trigger configured */ onUserMigration(handler: Trigger): void; /** * Verifies the authentication challenge response. * * ```ts * userPool.onVerifyAuthChallengeResponse(new Function(scope, id, async (event) => { * // handle event, set response properties, etc. * event.response... = .. * return event; * })); * ``` * * @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html * @default - no trigger configured */ onVerifyAuthChallengeResponse(handler: Trigger): void; } /** * An AWS Cognito User Pool. */ export interface IUserPool extends BaseUserPool { } /** * Defines an AWS Cognito User Pool. * * ```ts * const userPool = new UserPool(stack, "UserPool", { * lambdaTriggers: { * createAuthChallenge: new Function( * stack, * "CreateAuthChallenge", * async (event) => { * // implement logic for the CreateAuthChallenge lifecycle event * return event; * } * ), * }, * }); * ``` */ export declare class UserPool extends BaseUserPool implements IUserPool { /** * Create a {@link UserPool} from a pre-existing {@link aws_cognito.UserPool}. * * @param resource a pre-existing CDK User Pool L2 Construct. * @returns a Functionless {@link UserPool}. */ static from(resource: aws_cognito.UserPool): IUserPool; /** * Create a new AWS Cognito {@link UserPool}. * * @param scope Construct scope to instantiate the UserPool in. * @param id id of this UserPool within * @param props the {@link UserPoolProps}. * @see {@link aws_cognito.UserPool} */ constructor(scope: Construct, id: string, props?: UserPoolProps); } export {}; //# sourceMappingURL=user-pool.d.ts.map