feat: add preTokenGeneration trigger version support (v2_0, v3_0)#3131
Open
Ktsierra wants to merge 2 commits intoaws-amplify:mainfrom
Open
feat: add preTokenGeneration trigger version support (v2_0, v3_0)#3131Ktsierra wants to merge 2 commits intoaws-amplify:mainfrom
Ktsierra wants to merge 2 commits intoaws-amplify:mainfrom
Conversation
Allow users to specify a version for the preTokenGeneration trigger to enable access token customization on Essentials/Plus tier plans, without requiring CDK escape hatches. Fixes aws-amplify#1417
🦋 Changeset detectedLatest commit: 4e202b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR adds support for specifying the Cognito preTokenGeneration trigger “lambda version” (v1_0/v2_0/v3_0) when using defineAuth, enabling access token customization for tiers that require v2_0/v3_0 while keeping the plain handler form backward compatible.
Changes:
- Introduces
PreTokenGenerationVersionin@aws-amplify/auth-constructand exports it publicly. - Extends
defineAuthtrigger typing to allow{ handler, version }specifically forpreTokenGeneration. - Updates backend trigger wiring to use
PreTokenGenerationConfig+LambdaVersionwhenversionis provided, and adds unit tests for v1_0/v2_0/v3_0.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/backend-auth/src/factory.ts | Adds version-aware wiring for preTokenGeneration using PRE_TOKEN_GENERATION_CONFIG + LambdaVersion. |
| packages/backend-auth/src/factory.test.ts | Adds unit tests asserting PreTokenGenerationConfig and correct LambdaVersion for v1_0/v2_0/v3_0. |
| packages/backend-auth/API.md | Regenerates API docs to reflect the new triggers typing and exported type usage. |
| packages/auth-construct/src/types.ts | Adds the PreTokenGenerationVersion type with documentation. |
| packages/auth-construct/src/index.ts | Exports PreTokenGenerationVersion from the package entrypoint. |
| packages/auth-construct/API.md | Regenerates API docs to include the new public type. |
| .changeset/pre-token-generation-version.md | Declares a minor bump for both packages with the feature description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…Generation config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
defineAuth({ triggers: { preTokenGeneration } })always wires the trigger as V1 viaUserPoolOperation.of('preTokenGeneration')with nolambdaVersionargument. Users needing V2_0 or V3_0 (required for access token customization on Essentials/Plus tier) must bypassdefineAuthentirely with a CDK escape hatch.Issue number, if available: #1417
Changes
PreTokenGenerationVersiontype ('v1_0' | 'v2_0' | 'v3_0') to@aws-amplify/auth-constructtriggerstype inAmplifyAuthPropsto accept an object form{ handler, version }forpreTokenGenerationUserPoolOperation.PRE_TOKEN_GENERATION_CONFIGwith the correspondingLambdaVersionwhen version is specifiedCorresponding docs PR, if applicable: N/A
Validation
PreTokenGenerationConfigwith correctLambdaVersionin the CFN templatenpm run test: 113 backend-auth, 110 auth-construct, 0 failures)Checklist
run-e2elabel set.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.