Skip to content

Commit

Permalink
fix(auth): add inflightPromise in token orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
israx committed Mar 21, 2024
1 parent 1a6d358 commit 7698d53
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ import {
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

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Trailing spaces not allowed

Check failure on line 38 in packages/auth/src/providers/cognito/tokenProvider/TokenOrchestrator.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `↹↹`
return new Promise<void>((resolve, _reject) => {
addInflightPromise(resolve);
});

Check failure on line 41 in packages/auth/src/providers/cognito/tokenProvider/TokenOrchestrator.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `⏎`

};

setAuthConfig(authConfig: AuthConfig) {
Expand Down Expand Up @@ -83,6 +93,7 @@ export class TokenOrchestrator implements AuthTokenOrchestrator {
// Token provider not configured
return null;
}

await this.waitForInflightOAuth();
tokens = await this.getTokenStore().loadTokens();
const username = await this.getTokenStore().getLastAuthUser();
Expand Down

0 comments on commit 7698d53

Please sign in to comment.