user-management-sdk-js
Ad Astra user management SDK for JavaScript in the browser and Node.js
Tools
AuthManager (Class)
The AuthManager class can be used to:
Sign in a user through AWS's managed Cognito identity provider
.signIn( email, password, newPassword = '' )
=> Promise -> CognitoUserSession
Used to obtain a CognitoUserSession.
Get federated IAM credentials to access AWS resources
.getIamCredentials()
=> Promise -> CognitoIdentityCredentials
Returns a promise which resolbes a refreshable CognitoIdentityCredentials object after signing in. Typically, you will want to set your global AWS-SDK config object's credentials
key equal to this at the beginning of your session as follows:
import { config } from 'aws-sdk';
config.credentials = await authManagerInstance.getIamCredentials();
Refresh these credentials
.refreshCognitoCredentials()
=> Promise -> boolean
This will check if the credentials need refreshing using the credentials' .needsRefresh()
method. If it does, it will refresh and resolve true
. If it does not need refreshed, this will return false
.