UNPKG

aws-amplify

Version:

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

28 lines (26 loc) 1.35 kB
'use strict'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.createUserPoolsTokenProvider = void 0; const cognito_1 = require("@aws-amplify/auth/cognito"); /** * 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 cognito_1.DefaultTokenStore(); authTokenStore.setAuthConfig(authConfig); authTokenStore.setKeyValueStorage(keyValueStorage); const tokenOrchestrator = new cognito_1.TokenOrchestrator(); tokenOrchestrator.setAuthConfig(authConfig); tokenOrchestrator.setAuthTokenStore(authTokenStore); tokenOrchestrator.setTokenRefresher(cognito_1.refreshAuthTokensWithoutDedupe); return { getTokens: ({ forceRefresh } = { forceRefresh: false }) => tokenOrchestrator.getTokens({ forceRefresh }), }; }; exports.createUserPoolsTokenProvider = createUserPoolsTokenProvider; //# sourceMappingURL=createUserPoolsTokenProvider.js.map