@hatkom/aws-auth
v1.4.5
Published
A lightweight AWS Cognito authentication client built on top of `amazon-cognito-identity-js`.
Readme
AWS Auth Client
A lightweight AWS Cognito authentication client built on top of amazon-cognito-identity-js.
Install
npm i @hatkom/aws-authUsage
import { AWSAuthClient } from '@hatkom/aws-auth'
const auth = new AWSAuthClient('us-east-1_xxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxx')
// Sign in
const session = await auth.authenticateUser({ email: '[email protected]', password: 'password' })
// Get current session token (auto-refreshes if expired)
const token = await auth.getCurrentSessionToken()
// Sign out
await auth.signOut()API
authenticateUser({ email, password })— sign in, returns session or'new-password-required'getCurrentSessionToken()— returns current access JWT, refreshing if neededsignOut()— signs out the current usercompleteNewPasswordChallenge({ username, newPassword })— complete a new password challengeforgotPassword(username)— initiate forgot password flowforgotPasswordSubmit({ username, verificationCode, password })— submit new passwordresendVerificationCode(username)— resend email verification codeverifyUserEmail({ username, code })— confirm email registration
