UNPKG

aws-amplify

Version:

AWS Amplify is a JavaScript library for Frontend and mobile developers building cloud-enabled applications.

26 lines (23 loc) 1.23 kB
import { DefaultTokenStore, TokenOrchestrator, refreshAuthTokensWithoutDedupe } from '@aws-amplify/auth/cognito'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** * Creates an object that implements {@link TokenProvider}. * @param authConfig The Auth config that the credentials provider needs to function. * @param keyValueStorage An object that implements the {@link KeyValueStorageInterface}. * @returns An object that implements {@link TokenProvider}. */ const createUserPoolsTokenProvider = (authConfig, keyValueStorage) => { const authTokenStore = new DefaultTokenStore(); authTokenStore.setAuthConfig(authConfig); authTokenStore.setKeyValueStorage(keyValueStorage); const tokenOrchestrator = new TokenOrchestrator(); tokenOrchestrator.setAuthConfig(authConfig); tokenOrchestrator.setAuthTokenStore(authTokenStore); tokenOrchestrator.setTokenRefresher(refreshAuthTokensWithoutDedupe); return { getTokens: ({ forceRefresh } = { forceRefresh: false }) => tokenOrchestrator.getTokens({ forceRefresh }), }; }; export { createUserPoolsTokenProvider }; //# sourceMappingURL=createUserPoolsTokenProvider.mjs.map