@adastradev/user-management-sdk 中文文档教程

发布于 3年前 浏览 3 项目主页 更新于 3年前

user-management-sdk-js

codecov

适用于浏览器和 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

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

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文