-
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
fix(auth): add inflightPromise in token orchestrator #13158
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,20 +16,30 @@ | |
import { AuthError } from '../../../errors/AuthError'; | ||
import { CognitoAuthSignInDetails } from '../types'; | ||
|
||
import { | ||
Check failure on line 19 in packages/auth/src/providers/cognito/tokenProvider/TokenOrchestrator.ts GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth
|
||
AuthTokenOrchestrator, | ||
AuthTokenStore, | ||
CognitoAuthTokens, | ||
DeviceMetadata, | ||
TokenRefresher, | ||
} from './types'; | ||
import { oAuthStore } from '../utils/oauth'; | ||
import { addInflightPromise } from '../utils/oauth/inflightPromise'; | ||
|
||
export class TokenOrchestrator implements AuthTokenOrchestrator { | ||
private authConfig?: AuthConfig; | ||
tokenStore?: AuthTokenStore; | ||
tokenRefresher?: TokenRefresher; | ||
waitForInflightOAuth: () => Promise<void> = async () => { | ||
// no-op | ||
if (!(await oAuthStore.loadOAuthInFlight())) { | ||
return; | ||
} | ||
|
||
Check failure on line 38 in packages/auth/src/providers/cognito/tokenProvider/TokenOrchestrator.ts GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth
|
||
return new Promise<void>((resolve, _reject) => { | ||
addInflightPromise(resolve); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah good point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
|
||
}; | ||
|
||
setAuthConfig(authConfig: AuthConfig) { | ||
|
@@ -83,6 +93,7 @@ | |
// Token provider not configured | ||
return null; | ||
} | ||
|
||
await this.waitForInflightOAuth(); | ||
tokens = await this.getTokenStore().loadTokens(); | ||
const username = await this.getTokenStore().getLastAuthUser(); | ||
|
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.
Nit: Not a no-op anymore