Skip to content

Commit

Permalink
Revert "chore(auth): debounce refreshAuthTokens (#12845)"
Browse files Browse the repository at this point in the history
This reverts commit 5fc446e.
  • Loading branch information
david-mcafee committed Jan 18, 2024
1 parent 5fc446e commit 182b97a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import { AuthConfig } from '@aws-amplify/core';
import {
assertTokenProviderConfig,
decodeJWT,
deDupeAsyncFunction,
} from '@aws-amplify/core/internals/utils';
import { initiateAuth } from '../utils/clients/CognitoIdentityProvider';
import { getRegion } from '../utils/clients/CognitoIdentityProvider/utils';
import { assertAuthTokensWithRefreshToken } from '../utils/types';
import { AuthError } from '../../../errors/AuthError';
import { getUserContextData } from './userContextData';

const refreshAuthTokensFunction: TokenRefresher = async ({
export const refreshAuthTokens: TokenRefresher = async ({
tokens,
authConfig,
username,
Expand Down Expand Up @@ -73,5 +72,3 @@ const refreshAuthTokensFunction: TokenRefresher = async ({
username,
};
};

export const refreshAuthTokens = deDupeAsyncFunction(refreshAuthTokensFunction);
16 changes: 8 additions & 8 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@
"name": "[Analytics] record (Kinesis)",
"path": "./dist/esm/analytics/kinesis/index.mjs",
"import": "{ record }",
"limit": "44.48 kB"
"limit": "44.47 kB"
},
{
"name": "[Analytics] record (Kinesis Firehose)",
"path": "./dist/esm/analytics/kinesis-firehose/index.mjs",
"import": "{ record }",
"limit": "41.54 kB"
"limit": "41.50 kB"
},
{
"name": "[Analytics] record (Personalize)",
Expand Down Expand Up @@ -384,7 +384,7 @@
"name": "[Auth] confirmSignIn (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmSignIn }",
"limit": "25.94 kB"
"limit": "25.89 kB"
},
{
"name": "[Auth] updateMFAPreference (Cognito)",
Expand All @@ -396,19 +396,19 @@
"name": "[Auth] fetchMFAPreference (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ fetchMFAPreference }",
"limit": "8.35 kB"
"limit": "8.30 kB"
},
{
"name": "[Auth] verifyTOTPSetup (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ verifyTOTPSetup }",
"limit": "9.18 kB"
"limit": "9.13 kB"
},
{
"name": "[Auth] updatePassword (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ updatePassword }",
"limit": "9.19 kB"
"limit": "9.14 kB"
},
{
"name": "[Auth] setUpTOTP (Cognito)",
Expand All @@ -420,7 +420,7 @@
"name": "[Auth] updateUserAttributes (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ updateUserAttributes }",
"limit": "8.46 kB"
"limit": "8.41 kB"
},
{
"name": "[Auth] getCurrentUser (Cognito)",
Expand All @@ -432,7 +432,7 @@
"name": "[Auth] confirmUserAttribute (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmUserAttribute }",
"limit": "9.19 kB"
"limit": "9.15 kB"
},
{
"name": "[Auth] signInWithRedirect (Cognito)",
Expand Down
50 changes: 0 additions & 50 deletions packages/core/__tests__/utils/deDupeAsyncRequests.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/src/libraryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export {
retry,
urlSafeDecode,
urlSafeEncode,
deDupeAsyncFunction,
} from './utils';
export { parseAWSExports } from './parseAWSExports';
export { LegacyConfig } from './singleton/types';
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/singleton/apis/fetchAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';
import { Amplify } from '../Amplify';
import { FetchAuthSessionOptions } from '../Auth/types';
import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';

export const fetchAuthSession = (options?: FetchAuthSessionOptions) => {
export const fetchAuthSession = (
options?: FetchAuthSessionOptions
): Promise<AuthSession> => {
return fetchAuthSessionInternal(Amplify, options);
};
38 changes: 0 additions & 38 deletions packages/core/src/utils/deDupeAsyncFunction.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ export {
export { urlSafeDecode } from './urlSafeDecode';
export { urlSafeEncode } from './urlSafeEncode';
export { deepFreeze } from './deepFreeze';
export { deDupeAsyncFunction } from './deDupeAsyncFunction';
2 changes: 1 addition & 1 deletion packages/datastore/src/sync/processors/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class SubscriptionProcessor {

try {
// retrieving current token info from Cognito UserPools
const session = await fetchAuthSession();
const session = await await fetchAuthSession();
oidcTokenPayload = session.tokens?.idToken?.payload;
} catch (err) {
// best effort to get jwt from Cognito
Expand Down

0 comments on commit 182b97a

Please sign in to comment.