Inspired in this post Amazon Cognito User Pools in NodeJS as fast as possible thanks Prasad.
Cloud based painless wrapper library to handle authentication via AWS Cognito using JWT capabilities, on backend side, cognito defender has a good integration with express and nest.js framework.
In the early stages of projects we might to setup the Authentication and Authorisation features to grant access to specific users in the whole system, I wrapped the AWS Cognito identity library to use it on node.js backend and take the advantages to use AWS Cognito 50K first users FREE!
- user signing up
- user sign in
- forgot password
- confirm password
- verify email
- refresh jwt token
- MFA Setup: because the library used behind the scenes AWS Cognito really is made to be used on frontend side, then AWS Cognito require some interactions with the user to enable MFA which is not a good fit for API/Backend technologies.
- Install it:
npm i cognito defender # or yarn add cognito-defender
- Use it
import { CognitoDefender } from "cognito.defender";
const cognitoDefender = new CognitoDefender({
regionCognitoPool: 'your-region',
cognitoUserPoolId: 'pool-id',
cognitoClientId: 'client-id',
});
const userCreated = await cognitoDefender.login({
email: 'youremail@example.com',
password: 'super-secret',
});
- Allow to override payloads.
- Allow wrap Attributes
- Methods documentation
- improvements