Skip to content

Commit

Permalink
fix: Support tracking multiple inflight OAuth promise resolvers (#12482)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored Oct 31, 2023
1 parent 091f681 commit ad5c83e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"typings": "./lib-esm/index.d.ts",
"react-native": "./lib-esm/index.js",
"sideEffects": [
"./lib/providers/cognito/apis/signInWithOAuth.js",
"./lib-esm/providers/cognito/apis/signInWithOAuth.js"
"./lib/providers/cognito/apis/signInWithRedirect.js",
"./lib-esm/providers/cognito/apis/signInWithRedirect.js"
],
"publishConfig": {
"access": "public"
Expand Down
11 changes: 7 additions & 4 deletions packages/auth/src/providers/cognito/apis/signInWithRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,14 @@ function urlListener() {
isBrowser() && urlListener();

// This has a reference for listeners that requires to be notified, TokenOrchestrator use this for load tokens
let resolveInflightPromise = () => {};
let inflightPromiseResolvers: ((value: void | PromiseLike<void>) => void)[] =
[];

const invokeAndClearPromise = () => {
resolveInflightPromise();
resolveInflightPromise = () => {};
for (const promiseResolver of inflightPromiseResolvers) {
promiseResolver();
}
inflightPromiseResolvers = [];
};

isBrowser() &&
Expand All @@ -475,7 +478,7 @@ isBrowser() &&
if (!(await store.loadOAuthInFlight())) {
res();
} else {
resolveInflightPromise = res;
inflightPromiseResolvers.push(res);
}
return;
})
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
"name": "[Auth] confirmSignIn (Cognito)",
"path": "./lib-esm/auth/index.js",
"import": "{ confirmSignIn }",
"limit": "25.48 kB"
"limit": "25.55 kB"
},
{
"name": "[Auth] updateMFAPreference (Cognito)",
Expand Down Expand Up @@ -412,7 +412,7 @@
"name": "[Auth] OAuth Auth Flow (Cognito)",
"path": "./lib-esm/auth/index.js",
"import": "{ signInWithRedirect, signOut, fetchAuthSession }",
"limit": "19.53 kB"
"limit": "19.61 kB"
},
{
"name": "[Storage] copy (S3)",
Expand Down

0 comments on commit ad5c83e

Please sign in to comment.