fix(aws-amplify): sync Cognito auth config and merge libraryOptions on reconfigure - #14819
Merged
bobbor merged 5 commits intoJun 4, 2026
Conversation
…n reconfigure - Merge existing Amplify.libraryOptions when libraryOptions.Auth is provided so other categories are not dropped. - Call setAuthConfig on the default Cognito token provider when resourcesConfig.Auth changes on reconfigure (partial libraryOptions or config-only). - Merge prior libraryOptions on partial reconfigure without Auth override. - Add regression tests for the above behaviors. Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: ae174f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
…e singleton Validates Storage preservation and setAuthConfig on reconfigure without mocking @aws-amplify/core. Co-authored-by: Cursor <cursoragent@cursor.com>
3 tasks
ShrutiPundir17
force-pushed
the
fix/init-singleton-auth-config-reconfigure
branch
from
May 19, 2026 18:17
4d253c1 to
f67c651
Compare
Simplify initSingleton per maintainer feedback: pass-through when libraryOptions.Auth is set; otherwise always setAuthConfig and SSR-aware setKeyValueStorage. Removes libraryOptions merge from this PR. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Thanks for approval @bobbor One more review is required by other team member for merging, can you help with that. |
soberm
approved these changes
Jun 4, 2026
This was referenced Jun 4, 2026
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.
Solves issue : #14820
Description of changes
When DefaultAmplify.configure runs again with a new resourcesConfig.Auth but without libraryOptions.Auth, the default cognitoUserPoolsTokenProvider was not always refreshed. TokenStore storage keys depend on authConfig.Cognito.userPoolClientId, so tokens could read/write under stale keys after reconfigure (related to #13707).
Change (packages/aws-amplify/src/initSingleton.ts):
Pass-through to core when !resolvedResourceConfig.Auth or libraryOptions?.Auth is provided (caller owns Auth wiring).
Singleton-managed path (Auth in config, no libraryOptions.Auth): on every configure/reconfigure:
cognitoUserPoolsTokenProvider.setAuthConfig(resolvedResourceConfig.Auth)
cognitoUserPoolsTokenProvider.setKeyValueStorage(...) (SSR-aware: cookies vs defaultStorage)
Amplify.configure with default token + credentials providers
Out of scope: merging libraryOptions across configure calls (discussed on #14820; tracked separately in #14815 / #14816).
Issue #, if available
Fixes #14820
Related: #13707, #14815, #14816
Description of how you validated changes
cd packages/aws-amplify
....\node_modules.bin\jest.cmd initSingleton -w 1
Updated initSingleton.test.ts and initSingleton.integration.test.ts for pass-through vs refresh behavior.
Checklist
PR description included
yarn test passes (full monorepo — rely on CI)
Unit Tests are changed or added
Relevant documentation is changed or added
Checklist for repo maintainers
Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
New source file paths included in this PR have been added to CODEOWNERS, if appropriate
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.