简体   繁体   English

AWS Amplify 和 amazon-cognito-identity-js 之间的区别?

[英]The difference between AWS Amplify and amazon-cognito-identity-js?

I'm reviewing this demo of how to integrate Cognito with Angular, and it amazon-cognito-identity-js for the authorization service.我正在查看这个关于如何将 Cognito 与 Angular 集成的演示,以及用于授权服务的 amazon-cognito-identity-js

It seems that is what we should be using, but other tutorials install AWS Amplify as a whole:这似乎是我们应该使用的,但其他教程将AWS Amplify作为一个整体安装:

npm i aws-amplify

Curious what the difference is and whether one is more current than the other?好奇有什么区别,一个是否比另一个更流行?

amazon-cognito-identity-js used to be a separate package specifically for Cognito . amazon-cognito-identity-js曾经是专门针对Cognito的单独包。 Recently they've been bundling all their SDKs into Amplify to streamline the integration process.最近,他们将所有 SDK 捆绑到Amplify中以简化集成过程。

For instance in our iOS app the Cognito SDK had a number of issues that were resolved by moving to Amplify .例如,在我们的 iOS 应用程序中, Cognito SDK 有许多问题已通过迁移到Amplify得到解决。

As you can see in the link below, this package is now maintained in the Amplify umbrella.正如您在下面的链接中看到的,这个包现在在Amplify伞下维护。

https://github.com/aws-amplify/amplify-js/tree/master/packages/amazon-cognito-identity-js https://github.com/aws-amplify/amplify-js/tree/master/packages/amazon-cognito-identity-js

It used to be standalone here:它曾经在这里是独立的:

https://github.com/amazon-archives/amazon-cognito-identity-js https://github.com/amazon-archives/amazon-cognito-identity-js

I would recommend going forward with Amplify as that is the direction that AWS development is headed internally, and amazon-cognito-identity-js is maintained as part of Amplify anyway.我建议继续使用Amplify ,因为这是 AWS 内部开发的方向,并且amazon-cognito-identity-js无论如何都作为Amplify的一部分进行维护。

To add to the great answer by @DaveS.添加@DaveS 的精彩答案。 There are 3 official tools you can use to integrate Cognito in your app:您可以使用 3 种官方工具将 Cognito 集成到您的应用程序中:

Amplify 放大

  • Use it in client-side applications, where you'd use Amplify anyway - to leverage the premade auth UI components or to integrate with other services from the Amplify ecosystem: APIs, Analytics, Storage, etc.在客户端应用程序中使用它,无论如何您都会使用 Amplify - 以利用预制的身份验证 UI 组件或与来自 Amplify 生态系统的其他服务集成:API、分析、存储等。
  • Does not support secret-enabled Cognito app clients.不支持启用秘密的 Cognito 应用程序客户端。
  • Cannot make authenticated (requiring AWS credentials) Cognito API calls (eg adminCreateUser ) directly, but there's a workaround .无法直接进行经过身份验证(需要 AWS 凭证)的 Cognito API 调用(例如adminCreateUser ),但有一个解决方法

amazon-cognito-identity-js 亚马逊-cognito-identity-js

  • It is a much smaller package and it comes as a part of Amplify (hosted in the Amplify monorepo).它是一个小得多的包,它是 Amplify 的一部分(托管在 Amplify monorepo 中)。
  • It can still be used separately if you don't need any of the extra features provided by Amplify (save on the bundle size).如果您不需要 Amplify 提供的任何额外功能(节省包大小),它仍然可以单独使用。
  • Does not support secret-enabled Cognito app clients.不支持启用秘密的 Cognito 应用程序客户端。
  • Cannot make authenticated (requiring AWS credentials) Cognito API calls, eg adminCreateUser .无法进行经过身份验证(需要 AWS 凭证)的 Cognito API 调用,例如adminCreateUser
  • Can be used in the backend (unauthenticated Cognito APIs only).可以在后端使用(仅限未经身份验证的 Cognito API)。

AWS SDK 开发工具包

  • Low-level as it can get.尽其所能。
  • Provides access to all (authenticated and non-authenticated) Cognito APIs.提供对所有(经过身份验证和未经身份验证的)Cognito API 的访问。 For authenticated, make sure the code has access to AWS credentials.对于经过身份验证,请确保代码可以访问 AWS 凭证。
  • Can work with secret-enabled Cognito client apps (you need to sign the requests with the secret).可以使用启用秘密的 Cognito 客户端应用程序(您需要使用秘密签署请求)。
  • Can be used in both client (for unauthenticated APIs only, otherwise you're exposing secrets) and server applications.可用于客户端(仅用于未经身份验证的 API,否则您将暴露秘密)和服务器应用程序。

Code samples for all 3 can be found here: AWS Cognito: Amplify vs amazon-cognito-identity-js vs AWS SDK .可在此处找到所有 3 种代码示例: AWS Cognito:Amplify vs amazon-cognito-identity-js vs AWS SDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 amazon-cognito-identity-js 回调 - amazon-cognito-identity-js callbacks amazon-cognito-identity-js setupMFA 问题 - amazon-cognito-identity-js setupMFA problems AWS Cognito:在 Auth.signIn 中出现错误(验证 amazon-cognito-identity-js 已链接) - AWS Cognito: Getting error in Auth.signIn (Validate that amazon-cognito-identity-js has been linked) amazon-cognito-identity-js - 忘记了无效用户的密码 - amazon-cognito-identity-js - forgot password for Invalid User 使用 amazon-cognito-identity-js javascript 获取 idToken - Fetch the idToken using using amazon-cognito-identity-js javascript 任务 ':amazon-cognito-identity-js:javaPreCompileDebug' 执行失败 - Execution failed for task ':amazon-cognito-identity-js:javaPreCompileDebug' Angular + amazon-cognito-identity-js,为什么我收到错误:未定义全局 - Angular + amazon-cognito-identity-js, why am I getting error: global is not defined AWS Amplify 和 Cognito 身份验证 - AWS Amplify and Cognito Authentication AWS Amplify 中的 currentAuthenticatedUser() 和 currentUserPoolUser() 有什么区别? - what is difference between currentAuthenticatedUser() and currentUserPoolUser() in AWS Amplify? 如何使用 Amplify 字段将 JS 日期传递给 AWS Cognito DateTime - How to pass JS date to AWS Cognito DateTime using Amplify field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM