@nesn/commons-cognito-tools
v1.0.3
Published
Cognito tools
Downloads
62
Readme
@nesn/commons-cognito-tools
Overview
@nesn/commons-cognito-tools
is a utility package designed to simplify interactions with AWS Cognito. It provides functions to manage and query Cognito users efficiently.
Installation
To install the package, use npm:
Usage
Finding a Cognito User by Filter
You can use the findCognitoUserByFilter
function to find a user in a Cognito user pool by a specific filter.
import { findCognitoUserByFilter } from '@nesn/commons-cognito-tools';
const user = await findCognitoUserByFilter(
CognitoFilterType.EMAIL,
'[email protected]',
'user-pool-id',
{
region: 'your-region',
credentials: {
accessKeyId: 'your-access-key-id',
secretAccessKey: 'your-secret-access-key',
sessionToken: 'your-session-token'
}
}
);
API
findCognitoUserByFilter(filterType, filterValue, userPoolId, clientOptions)
- filterType:
CognitoFilterType
- The type of filter to apply (e.g., EMAIL, USERNAME). - filterValue:
string
- The value to filter by. - userPoolId:
string
- The ID of the Cognito user pool. - clientOptions:
object
- AWS client configuration options.
Returns a Promise
that resolves to a CognitoUser
object or null
if no user is found.
License
This project is licensed under the MIT License - see the LICENSE file for details.