UNPKG

aws-amplify

Version:

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

31 lines (27 loc) 1.05 kB
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import { CognitoAWSCredentialsAndIdentityIdProvider, DefaultIdentityIdStore, } from '@aws-amplify/auth/cognito'; import { AuthConfig, CredentialsAndIdentityIdProvider, KeyValueStorageInterface, } from '@aws-amplify/core'; /** * Creates a instance of {@link CognitoAWSCredentialsAndIdentityIdProvider} using * the provided `keyValueStorage`. * @param authConfig The Auth config that the credentials provider needs to function. * @param keyValueStorage An object that implements the {@link KeyValueStorageInterface}. * @returns An instance of {@link CognitoAWSCredentialsAndIdentityIdProvider}. */ export const createAWSCredentialsAndIdentityIdProvider = ( authConfig: AuthConfig, keyValueStorage: KeyValueStorageInterface, ): CredentialsAndIdentityIdProvider => { const credentialsProvider = new CognitoAWSCredentialsAndIdentityIdProvider( new DefaultIdentityIdStore(keyValueStorage), ); return credentialsProvider; };