{"version":3,"file":"createUserPoolsTokenProvider.mjs","sources":["../../../../../src/adapter-core/authProvidersFactories/cognito/createUserPoolsTokenProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { DefaultTokenStore, TokenOrchestrator, refreshAuthTokensWithoutDedupe, } from '@aws-amplify/auth/cognito';\nimport { registerContextTokenOrchestrator } from '@aws-amplify/core/internals/utils';\n/**\n * Creates an object that implements {@link TokenProvider}.\n * @param authConfig The Auth config that the credentials provider needs to function.\n * @param keyValueStorage An object that implements the {@link KeyValueStorageInterface}.\n * @returns An object that implements {@link TokenProvider}.\n */\nexport const createUserPoolsTokenProvider = (authConfig, keyValueStorage) => {\n    const authTokenStore = new DefaultTokenStore();\n    authTokenStore.setAuthConfig(authConfig);\n    authTokenStore.setKeyValueStorage(keyValueStorage);\n    const tokenOrchestrator = new TokenOrchestrator();\n    tokenOrchestrator.setAuthConfig(authConfig);\n    tokenOrchestrator.setAuthTokenStore(authTokenStore);\n    tokenOrchestrator.setTokenRefresher(refreshAuthTokensWithoutDedupe);\n    const provider = {\n        getTokens: ({ forceRefresh } = { forceRefresh: false }) => tokenOrchestrator.getTokens({ forceRefresh }),\n    };\n    // Register the per-context orchestrator so token writes performed through a\n    // local context (e.g. `createAmplifyContext`) can be routed to this\n    // write-capable orchestrator instead of the global singleton.\n    registerContextTokenOrchestrator(provider, tokenOrchestrator);\n    return provider;\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,CAAC,UAAU,EAAE,eAAe,KAAK;AAC7E,IAAI,MAAM,cAAc,GAAG,IAAI,iBAAiB,EAAE;AAClD,IAAI,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC;AAC5C,IAAI,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC;AACtD,IAAI,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE;AACrD,IAAI,iBAAiB,CAAC,aAAa,CAAC,UAAU,CAAC;AAC/C,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,CAAC;AACvD,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,8BAA8B,CAAC;AACvE,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,iBAAiB,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;AAChH,KAAK;AACL;AACA;AACA;AACA,IAAI,gCAAgC,CAAC,QAAQ,EAAE,iBAAiB,CAAC;AACjE,IAAI,OAAO,QAAQ;AACnB;;;;"}