-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(parser): add Cognito pre-signup trigger schema #3729
base: main
Are you sure you want to change the base?
feat(parser): add Cognito pre-signup trigger schema #3729
Conversation
Hi @VatsalGoel3 - thank you for the PR. I think we didn't do a good job at explaining the requirements for the issue and as a result this PR needs considerably more work. I have left a new comment in the linked issue (here) please take a look and let me know if you have any questions. We need to incorporate everything from that comment before we can merge this PR. |
- Implemented 12 new Zod schemas for Cognito Lambda triggers: - Pre-Signup, Post-Confirmation, Pre-Authentication, Post-Authentication - Pre-Token Generation (V1 & V2), Migrate User - Custom Message, Custom Email Sender, Custom SMS Sender - Define Auth Challenge, Create Auth Challenge, Verify Auth Challenge - Updated schemas/index.ts for dedicated exports - Added unit tests in cognito.test.ts following Prepare/Act/Assess format
@dreamorosi, I have added the 12 schemas as you mentioned, I had a query for the Challenge Result Schema, currently I have just defined it as an empty object and in tests for DefineAuth and CreateAuth schemas i have defined the Challenge Schema as I understand it would look like, let me know what updates would it require if any. Also after this comment, I will update the PR message to explain more in detail the feature. |
…with a generic placeholder
|
Hi thanks for the PR - I'll try to review it tomorrow. |
Hey @VatsalGoel3 - sorry for the delays on this PR. I've been busy with the 2.17.0 release, which includes your work on the Validation utility and I haven't been able to get to this one. I have blocked some time on Thursday (2hrs) to deploy a Cognito User Pool and test the schemas there. After that I'll provide a review, thanks for your patience. |
@dreamorosi Hey, no worries, hope you got some time to check it out yesterday, also I would love to contribute more, maybe in testing and further task if that is something I can help with, would love to understand the end to end workflow. |
Summary
Changes
This PR adds comprehensive Cognito trigger schemas to the Parser utility. The new schemas are implemented using Zod and ensure that AWS Cognito Lambda triggers conform to the expected event structures. The updates cover all 12 trigger types, including:
Pre-Signup Trigger: Validates events when users sign up.
Post-Confirmation Trigger: Validates events after user confirmation.
Pre-Authentication Trigger: Validates events prior to authentication.
Post-Authentication Trigger: Validates events after authentication.
Pre-Token Generation Trigger (V1 & V2): Validates events before token generation.
Migrate User Trigger: Validates events for user migration during sign-in or forgot-password flows.
Custom Message Trigger: Validates events for custom message modifications.
Custom Email Sender Trigger: Validates events for custom email sender functions (with an empty response object).
Custom SMS Sender Trigger: Validates events for custom SMS sender functions.
Define Auth Challenge Trigger: Validates events for initiating a custom auth challenge flow.
Create Auth Challenge Trigger: Validates events that create challenge details for custom authentication.
Verify Auth Challenge Trigger: Validates events that verify the user’s answer to a custom challenge.
Key changes include:
Implemented the new schemas in packages/parser/src/schemas/cognito.ts using Zod.
Updated packages/parser/src/schemas/index.ts to export all new Cognito trigger schemas.
Added and updated unit tests in packages/parser/tests/unit/schemas/cognito.test.ts to cover valid and invalid event payloads using the Prepare/Act/Assess format.
Ensured 100% test coverage for the new schemas.
Resolved Node.js import issues in index files to meet repository linting standards.
Issue number: #3675
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.