@adastradev/user-management-sdk 中文文档教程
user-management-sdk-js
适用于浏览器和 Node.js 中的 JavaScript 的 Ad Astra 用户管理 SDK
Tools
AuthManager (Class)
AuthManager 类可用于:
Sign in a user through AWS's managed Cognito identity provider
.signIn( 邮箱, 密码, newPassword = '' )
=> 承诺-> CognitoUserSession
用于获取CognitoUserSession。
Get/refresh credentials, and set environment credentials with one function
<代码>.getAndSetEnvironmentCredentials() => 承诺-> CognitoIdentityCredentials
这将从 CognitoIdentityCredentials 对象设置以下环境变量:
process.env.AWS_ACCESS_KEY_ID
process.env.AWS_SECRET_ACCESS_KEY
process.env.AWS_SESSION_TOKEN
此函数等效于:
const creds = await authManagerInstance.refreshCognitoCredentials();
authManagerInstance.setEnvironmentIAMCreds(creds);
Get/refresh cognito credentials, and federated identity credentials
<代码>.refreshCognitoCredentials() => 承诺-> CognitoIdentityCredentials
登录后返回解析新 CognitoIdentityCredentials 对象的承诺强>.
Set credentials in the environment
.setEnvironmentIAMCreds(creds: CognitoIdentityCredentials)
=> => void
这将从 CognitoIdentityCredentials 对象设置以下环境变量:
process.env.AWS_ACCESS_KEY_ID
process.env.AWS_SECRET_ACCESS_KEY
process.env.AWS_SESSION_TOKEN
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/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