Astra user management SDK for JavaScript in the browser and Node.js


License
MIT
Install
npm install @adastradev/user-management-sdk@2.4.16-beta.1632921063434

Documentation

user-management-sdk-js

codecov

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/refresh credentials, and set environment credentials with one function

.getAndSetEnvironmentCredentials() => Promise -> CognitoIdentityCredentials

This will set the following environment variables from the CognitoIdentityCredentials object:

process.env.AWS_ACCESS_KEY_ID
process.env.AWS_SECRET_ACCESS_KEY
process.env.AWS_SESSION_TOKEN

This function is equivalent to:

const creds = await authManagerInstance.refreshCognitoCredentials();
authManagerInstance.setEnvironmentIAMCreds(creds);
Get/refresh cognito credentials, and federated identity credentials

.refreshCognitoCredentials() => Promise -> CognitoIdentityCredentials

Returns a promise which resolves a fresh CognitoIdentityCredentials object after signing in.

Set credentials in the environment

.setEnvironmentIAMCreds(creds: CognitoIdentityCredentials) => void

This will set the following environment variables from the CognitoIdentityCredentials object:

process.env.AWS_ACCESS_KEY_ID
process.env.AWS_SECRET_ACCESS_KEY
process.env.AWS_SESSION_TOKEN