-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(auth): standalone enable oauth listener for MPAs #12731
Conversation
Please ensure that this PR:
A repository administrator is required to review & merge this change. |
|
||
/** @internal */ | ||
[ADD_OAUTH_LISTENER](listener: (authConfig: AuthConfig['Cognito']) => void) { | ||
if (this.resourcesConfig.Auth?.Cognito.loginWith?.oauth) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't use the assertion function here to reduce bundle size impact...
|
||
private notifyOAuthListener() { | ||
if ( | ||
!this.resourcesConfig.Auth?.Cognito.loginWith?.oauth || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, Bundle size impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good! Thank you @HuiSF
packages/auth/src/providers/cognito/utils/oauth/inflightPromiseManager.ts
Outdated
Show resolved
Hide resolved
dc3e30b
to
4a5313a
Compare
4a5313a
to
e69f132
Compare
packages/auth/src/providers/cognito/utils/oauth/attemptCompleteOAuthFlow.ts
Outdated
Show resolved
Hide resolved
e69f132
to
cebf03d
Compare
6711470
to
5d64565
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I smoked test these changes with a React App and works fine!
5d64565
to
b93ceb4
Compare
Co-authored-by: Israel Arcos <israel.arcos2595@gmail.com>
b93ceb4
to
df1957e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Lets release to the preview tag first for further testing and validation of this change.
…plify#12731)" This reverts commit 94d1fb2.
Description of changes
This PR introduces an importable and standalone side effect for enabling the OAuth listener for
signInWithRedirect
API in multipage app use cases.Developers should be able to
import 'aws-amplify/auth/enable-oauth-listener'
in a route (as thesignInWithRedirect
redirect url) to complete the OAuth sign in flow.signInWithRedirect
implementationAmplify
singleton where whether the singleton has a validOAuth
config is the single trigger of the listener - this prevents the listener to be executed multiple times on repetitive calls ofAmplify.configure
when someone tries manual configurationssignInWithRedirect
and side effect implementationIssue #, if available
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.