diff --git a/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createAWSCredentialsAndIdentityIdProvider.ts b/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createAWSCredentialsAndIdentityIdProvider.ts index 521ab0bc072..7760abef0e0 100644 --- a/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createAWSCredentialsAndIdentityIdProvider.ts +++ b/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createAWSCredentialsAndIdentityIdProvider.ts @@ -6,8 +6,8 @@ import { DefaultIdentityIdStore, } from '@aws-amplify/auth/cognito'; import { - CredentialsAndIdentityIdProvider, AuthConfig, + CredentialsAndIdentityIdProvider, KeyValueStorageInterface, } from '@aws-amplify/core'; @@ -20,10 +20,11 @@ import { */ export const createAWSCredentialsAndIdentityIdProvider = ( authConfig: AuthConfig, - keyValueStorage: KeyValueStorageInterface + keyValueStorage: KeyValueStorageInterface, ): CredentialsAndIdentityIdProvider => { const credentialsProvider = new CognitoAWSCredentialsAndIdentityIdProvider( - new DefaultIdentityIdStore(keyValueStorage) + new DefaultIdentityIdStore(keyValueStorage), ); + return credentialsProvider; }; diff --git a/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createUserPoolsTokenProvider.ts b/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createUserPoolsTokenProvider.ts index f739d28f0b5..8e7a0ee9ed3 100644 --- a/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createUserPoolsTokenProvider.ts +++ b/packages/aws-amplify/src/adapterCore/authProvidersFactories/cognito/createUserPoolsTokenProvider.ts @@ -20,7 +20,7 @@ import { */ export const createUserPoolsTokenProvider = ( authConfig: AuthConfig, - keyValueStorage: KeyValueStorageInterface + keyValueStorage: KeyValueStorageInterface, ): TokenProvider => { const authTokenStore = new DefaultTokenStore(); authTokenStore.setAuthConfig(authConfig); diff --git a/packages/aws-amplify/src/adapterCore/runWithAmplifyServerContext.ts b/packages/aws-amplify/src/adapterCore/runWithAmplifyServerContext.ts index 021bfbe0aac..9bb6d3b38e3 100644 --- a/packages/aws-amplify/src/adapterCore/runWithAmplifyServerContext.ts +++ b/packages/aws-amplify/src/adapterCore/runWithAmplifyServerContext.ts @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 import { + AmplifyServer, createAmplifyServerContext, destroyAmplifyServerContext, - AmplifyServer, } from '@aws-amplify/core/internals/adapter-core'; /** @@ -22,7 +22,7 @@ export const runWithAmplifyServerContext: AmplifyServer.RunOperationWithContext async (amplifyConfig, libraryOptions, operation) => { const contextSpec = createAmplifyServerContext( amplifyConfig, - libraryOptions + libraryOptions, ); // run the operation with injecting the context diff --git a/packages/aws-amplify/src/adapterCore/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts b/packages/aws-amplify/src/adapterCore/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts index a7a33025bda..dffd9bc4752 100644 --- a/packages/aws-amplify/src/adapterCore/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts +++ b/packages/aws-amplify/src/adapterCore/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts @@ -17,7 +17,7 @@ const ONE_YEAR_IN_MS = 365 * 24 * 60 * 60 * 1000; * @returns An object that implements {@link KeyValueStorageInterface}. */ export const createKeyValueStorageFromCookieStorageAdapter = ( - cookieStorageAdapter: CookieStorage.Adapter + cookieStorageAdapter: CookieStorage.Adapter, ): KeyValueStorageInterface => { return { setItem(key, value) { @@ -26,14 +26,17 @@ export const createKeyValueStorageFromCookieStorageAdapter = ( ...defaultSetCookieOptions, expires: new Date(Date.now() + ONE_YEAR_IN_MS), }); + return Promise.resolve(); }, getItem(key) { const cookie = cookieStorageAdapter.get(key); + return Promise.resolve(cookie?.value ?? null); }, removeItem(key) { cookieStorageAdapter.delete(key); + return Promise.resolve(); }, clear() { diff --git a/packages/aws-amplify/src/analytics/index.ts b/packages/aws-amplify/src/analytics/index.ts index be0ceb9180b..8ce900eca6b 100644 --- a/packages/aws-amplify/src/analytics/index.ts +++ b/packages/aws-amplify/src/analytics/index.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 /* -This file maps exports from `aws-amplify/analytics`. It provides access to the default Analytics provider and category +This file maps exports from `aws-amplify/analytics`. It provides access to the default Analytics provider and category utils. */ export * from '@aws-amplify/analytics'; diff --git a/packages/aws-amplify/src/in-app-messaging/pinpoint/index.ts b/packages/aws-amplify/src/in-app-messaging/pinpoint/index.ts index 3c031e7362c..5d6340ed298 100644 --- a/packages/aws-amplify/src/in-app-messaging/pinpoint/index.ts +++ b/packages/aws-amplify/src/in-app-messaging/pinpoint/index.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 /* -This file maps exports from `aws-amplify/in-app-messaging/pinpoint`. +This file maps exports from `aws-amplify/in-app-messaging/pinpoint`. It provides access to the Pinpoint provider of the InAppMessaging sub-category. */ export * from '@aws-amplify/notifications/in-app-messaging/pinpoint'; diff --git a/packages/aws-amplify/src/initSingleton.ts b/packages/aws-amplify/src/initSingleton.ts index 748012baf14..785ed9fd214 100644 --- a/packages/aws-amplify/src/initSingleton.ts +++ b/packages/aws-amplify/src/initSingleton.ts @@ -11,9 +11,10 @@ import { LegacyConfig, parseAWSExports, } from '@aws-amplify/core/internals/utils'; + import { - cognitoUserPoolsTokenProvider, cognitoCredentialsProvider, + cognitoUserPoolsTokenProvider, } from './auth/cognito'; export const DefaultAmplify = { @@ -31,7 +32,7 @@ export const DefaultAmplify = { */ configure( resourceConfig: ResourcesConfig | LegacyConfig, - libraryOptions?: LibraryOptions + libraryOptions?: LibraryOptions, ): void { let resolvedResourceConfig: ResourcesConfig; @@ -44,13 +45,17 @@ export const DefaultAmplify = { // If no Auth config is provided, no special handling will be required, configure as is. // Otherwise, we can assume an Auth config is provided from here on. if (!resolvedResourceConfig.Auth) { - return Amplify.configure(resolvedResourceConfig, libraryOptions); + Amplify.configure(resolvedResourceConfig, libraryOptions); + + return; } // If Auth options are provided, always just configure as is. // Otherwise, we can assume no Auth libraryOptions were provided from here on. if (libraryOptions?.Auth) { - return Amplify.configure(resolvedResourceConfig, libraryOptions); + Amplify.configure(resolvedResourceConfig, libraryOptions); + + return; } // If no Auth libraryOptions were previously configured, then always add default providers. @@ -60,15 +65,18 @@ export const DefaultAmplify = { // TODO: allow configure with a public interface libraryOptions?.ssr ? new CookieStorage({ sameSite: 'lax' }) - : defaultStorage + : defaultStorage, ); - return Amplify.configure(resolvedResourceConfig, { + + Amplify.configure(resolvedResourceConfig, { ...libraryOptions, Auth: { tokenProvider: cognitoUserPoolsTokenProvider, credentialsProvider: cognitoCredentialsProvider, }, }); + + return; } // At this point, Auth libraryOptions would have been previously configured and no overriding @@ -80,13 +88,16 @@ export const DefaultAmplify = { // TODO: allow configure with a public interface libraryOptions.ssr ? new CookieStorage({ sameSite: 'lax' }) - : defaultStorage + : defaultStorage, ); } - return Amplify.configure(resolvedResourceConfig, { + + Amplify.configure(resolvedResourceConfig, { Auth: Amplify.libraryOptions.Auth, ...libraryOptions, }); + + return; } // Finally, if there were no libraryOptions given at all, we should simply not touch the currently diff --git a/packages/aws-amplify/src/push-notifications/pinpoint/index.ts b/packages/aws-amplify/src/push-notifications/pinpoint/index.ts index 271aa62fbba..f5dbc056b56 100644 --- a/packages/aws-amplify/src/push-notifications/pinpoint/index.ts +++ b/packages/aws-amplify/src/push-notifications/pinpoint/index.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 /* -This file maps exports from `aws-amplify/push-notifications/pinpoint`. +This file maps exports from `aws-amplify/push-notifications/pinpoint`. It provides access to the Pinpoint provider of the PushNotification sub-category. */ export * from '@aws-amplify/notifications/push-notifications/pinpoint';