Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

VatsalGoel3
Copy link
Contributor

@VatsalGoel3 VatsalGoel3 commented Mar 17, 2025

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.

@boring-cyborg boring-cyborg bot added parser This item relates to the Parser Utility tests PRs that add or change tests labels Mar 17, 2025
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Mar 17, 2025
@dreamorosi
Copy link
Contributor

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.

@dreamorosi dreamorosi marked this pull request as draft March 17, 2025 16:44
@dreamorosi dreamorosi linked an issue Mar 17, 2025 that may be closed by this pull request
2 tasks
- 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
@pull-request-size pull-request-size bot added size/XXL PRs with 1K+ LOC, largely documentation related and removed size/M PR between 30-99 LOC labels Mar 18, 2025
@boring-cyborg boring-cyborg bot added the dependencies Changes that touch dependencies, e.g. Dependabot, etc. label Mar 18, 2025
@VatsalGoel3
Copy link
Contributor Author

VatsalGoel3 commented Mar 18, 2025

@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.

@VatsalGoel3 VatsalGoel3 marked this pull request as ready for review March 18, 2025 08:47
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@dreamorosi
Copy link
Contributor

Hi thanks for the PR - I'll try to review it tomorrow.

@dreamorosi
Copy link
Contributor

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.

@VatsalGoel3
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Changes that touch dependencies, e.g. Dependabot, etc. parser This item relates to the Parser Utility size/XXL PRs with 1K+ LOC, largely documentation related tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add Cognito trigger schemas
2 participants