amplify-js | declarative JavaScript library for application development | AWS library

 by   aws-amplify TypeScript Version: aws-amplify@5.2.5 License: Apache-2.0

kandi X-RAY | amplify-js Summary

kandi X-RAY | amplify-js Summary

amplify-js is a TypeScript library typically used in Cloud, AWS, React, Amazon S3 applications. amplify-js has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. AWS Amplify goes well with any JavaScript based frontend workflow and React Native for mobile developers. Our default implementation works with Amazon Web Services (AWS), but AWS Amplify is designed to be open and pluggable for any custom backend or service.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              amplify-js has a medium active ecosystem.
              It has 9224 star(s) with 2067 fork(s). There are 228 watchers for this library.
              There were 6 major release(s) in the last 12 months.
              There are 529 open issues and 5258 have been closed. On average issues are closed in 138 days. There are 85 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of amplify-js is aws-amplify@5.2.5

            kandi-Quality Quality

              amplify-js has no bugs reported.

            kandi-Security Security

              amplify-js has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              amplify-js is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              amplify-js releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of amplify-js
            Get all kandi verified functions for this library.

            amplify-js Key Features

            No Key Features are available at this moment for amplify-js.

            amplify-js Examples and Code Snippets

            Moving aws-exports.js to another Angular Project?
            Lines of Code : 10dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import Amplify from '@aws-amplify/core'
            import { Auth } from '@aws-amplify/auth'
            import awsconfig from './aws-exports'
            
            Amplify.configure(awsconfig)
            Auth.configure(awsconfig)
            
            
            Amplify.configure(awsconfig)
            
            Can not connect to AWS Amplify PubSub -> Socket error:undefined
            Lines of Code : 6dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            yarn add amazon-cognito-identity-js
            
            {
              "message": "Hello from AWS IoT console"
            }
            
            Force the login page using Amplify with Nuxt.js
            JavaScriptdot img3Lines of Code : 27dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import { Auth } from 'aws-amplify'
            
            export default {
              async mounted() {
                if (this.$store.state.account.authorized) {
                  return
                }
            
                try {
                  let user = await Auth.currentAuthenticatedUser({ bypassCache: false })
                  if (!
            How to persist CognitoUser during signIn with CUSTOM_AUTH authentication flow
            JavaScriptdot img4Lines of Code : 54dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import Auth from '@aws-amplify/auth'
            import { CognitoUser } from 'amazon-cognito-identity-js'
            
            const CUSTOM_AUTH_TTL = 5 * 60 * 1000 // Milliseconds
            
            interface CustomAuthSession {
              username: string
              session: string
              // Milliseconds afte
            Flow for authentication when MFA required for user in AWS Cognito
            JavaScriptdot img5Lines of Code : 67dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import Amplify from 'aws-amplify'
            import Auth from '@aws-amplify/auth'
            
            let mfaRequired = false
            
            Amplify.configure({
                Auth: {
                    userPoolWebClientId: '',
                    userPoolId: ''
                }
            })
            
            const logUserIn = (user) => {
              // Go for
            Is it possible to use the amplify framework without using the cli?
            Lines of Code : 22dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            npm install --save aws-amplify
            npm install --save aws-amplify-react
            
            Amplify.configure({
                "aws_project_region": process.env.REACT_APP_REGION,
                "aws_cognito_identity_pool_id": process.env.REACT_APP_IDENTITY_POO
            Can we use AWS amplify only for its react library (components) but not the backend cli?
            JavaScriptdot img7Lines of Code : 30dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            npm i aws-amplify --save
            
            import Amplify, { Auth } from 'aws-amplify'
            
            Amplify.configure({
              Auth: {
                region: process.env.AWS_REGION,
                identityPoolId: process.env.IDENTITY_POOL_ID,
                userPoolId: process.env.
            How to insert public url from image stored in AWS S3 into JSX component?
            Lines of Code : 41dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import { Storage } from 'aws-amplify'
            
            const getImgUrl = key => {
                return Storage.get(key)
                .then(res => (res))
                .catch(err => console.log(err))
              }
            
            class Image extends Component {
               this.state = {
                 imgSrc: null
               
            Authenticating user in AWS Cognito User/Identity Pool with Google as identity provider
            JavaScriptdot img9Lines of Code : 6dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import Amplify from 'aws-amplify'
            
            import Amplify from '@aws-amplify/core'
            
            import Auth from '@aws-amplify/auth'
            
            How to get use details by username in node js with amplify-js
            JavaScriptdot img10Lines of Code : 29dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import Amplify from 'aws-amplify'
            var AWS = require('aws-sdk')
            const CognitoExpress = require('cognito-express')
            
            import { CognitoUserPool, CognitoUser } from 'amazon-cognito-identity-js'
            exports.getUsersFromUserPool = (paramsObject, userP

            Community Discussions

            QUESTION

            How to use AWS amplify securely
            Asked 2021-Dec-23 at 13:36

            I'm experimenting with AWS amplify. In particular, looking to provide a means for a user to change their cognito password. I don't understand how that is done in a secure fashion given the client id is exposed.

            What am I missing?

            Here are the docs for what I'm using....

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

            ...

            ANSWER

            Answered 2021-Dec-23 at 13:36

            Amplify uses amazon-cognito-identity-js under the hood. So use Auth module from Amplify(aws-amplify).

            Source https://stackoverflow.com/questions/70453939

            QUESTION

            What's the equivalent of CognitoIdentityCredentials for user pool?
            Asked 2021-Nov-16 at 13:46

            I have a user pool in Cognito, and right now I'm following https://github.com/aws-amplify/amplify-js/tree/main/packages/amazon-cognito-identity-js to authenticate user. I'm not using Amplify btw.

            However in above link, I can only see example of authentication for identity pool.

            ...

            ANSWER

            Answered 2021-Nov-15 at 07:43

            Cognito Identity JS is for identity pools i believe. Here's the javascript method to sign in to user pool and retrieve tokens. https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#initiateAuth-property

            Source https://stackoverflow.com/questions/69958161

            QUESTION

            How to mock Auth.currentSession()?
            Asked 2021-Sep-21 at 12:59

            I try to mock Auth.currentSession() for jest testing.

            I tried to write code according to this article.
            https://github.com/aws-amplify/amplify-js/issues/3605

            But it does not work. It makes compile errors.

            ...

            ANSWER

            Answered 2021-Sep-21 at 12:59

            I just can avoid compile error by adding @ts-ignore

            Source https://stackoverflow.com/questions/69268351

            QUESTION

            Amazon Cognito throws an error if I try to sign in a second time with social sign in (Google/Oauth)
            Asked 2021-Sep-15 at 07:24

            I am writing here to ask for help or at least a clarification.

            I work at a startup and a couple of weeks ago we launched our SaaS. We manage all our users with Aws Cognito. I'm using amazon-cognito-identity-js for the authentication on the frontend and both sign-up and sign-in work fine. We want to add social sign-in (OAuth) through Google and for that I'm using aws-amplify-js, calling Auth.federatedSignIn({provider: 'Google'}) as specified in Amplify docs.

            The first time a user sign in with Google, a new user is correctly created in Cognito, but if I try to sign in again with the same user I get the following error: #error_description=Invalid+user+attributes%3A+email%3A+Attribute+cannot+be+updated.%0A+&error=invalid_request.

            Apparently this is a rather common issue:

            After looking for a solution I believe this happens because when we created our User Pool we set email as a required attribute and it was automatically set as immutable. Apparently if you want to use social sign-in every attribute should be mutable (as specified here because on every new sign in Cognito tries to update them.

            So now we're stuck. It's not possible to change email attribute from immutable to mutable for an existing User Pool and as far as I know it's not possible to prevent Auth.federatedSignIn({provider: 'Google'}) to update every user attributes.

            We cannot simply delete and recreate our User Pool because we're already in production and we got several users already registered. Is there any possible solution or workaround to fix this? Any kind of suggestion would be very helpful!

            ...

            ANSWER

            Answered 2021-Sep-15 at 07:24

            As of now there is nothing more you could do then to migrate all the users to another User Pool.

            For users using federated sign in this won't change anything. You don't store their passwords so they won't see any difference.

            The problem starts with users for which you has passwords. While you can migrate them to another pool, they will have to set up a new password.

            You could write a simple script that could create a CSV file with the user data and then use the import function of the new User Pool to import all users. All non-federate users will then need to set new password.

            You can just notify all of them that this will be happening because the whole operation will involve some downtime (since you don't want the two pools to get out of sync).

            Source https://stackoverflow.com/questions/69188292

            QUESTION

            React Native: What is returned by Auth.signIn()?
            Asked 2021-Jun-18 at 14:39

            I am developing using react-native with Amazon AWS as back-end. I am also using amplify library.

            For logging in, I am using the below call:

            const user = await Auth.signIn(...)

            https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js#sign-in

            https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#signin

            My related questions:

            1. I get a big JSON in the user variable. I believe it is the AWS credential?

            2. The above signIn() call DOES NOT return a JWT token, it returns AWS credential. Is it? Also see the post:- https://stackoverflow.com/a/59327655/15943787

              Above post mentions:

            After successfully authenticating a user, Amazon Cognito issues JSON web tokens (JWT) that you can use to secure and authorize access to your own APIs, or exchange for AWS credentials

            What is meant by above statement? What is Auth.signIn() doing? getting JWT token or credentials?

            1. Does this returned credential get stored inside the mobile device? By default in android it is stored un-encrypted. Right?

            2. Is it stored in sharedPreferences?

            ...

            ANSWER

            Answered 2021-Jun-18 at 14:39

            The Auth.signIn() returns a CognitoUser Object as defined in the API Docs.

            Below is from AWS SDK for Android but the data in Javascript is the same, (found here). The JWT Token in stored in the CognitoUser.CognitoUserSession attribute.

            Represents a single Cognito User. This class encapsulates all operations possible on a user and all tokens belonging to the user. The user tokens, as CognitoUserSession, are stored in SharedPreferences. Only the tokens belonging to the last successfully authenticated user are stored

            So to answer your questions:

            1. I get a big JSON in the user variable. I believe it is the AWS credential?

            The user variable is a CognitoUser Object, which represents a single CognitoUser. to get the JWT token try user.sessionId or user.tokenId

            1. The above signIn() call DOES NOT return a JWT token, it returns AWS credential. Is it? Also see the post:- https://stackoverflow.com/a/59327655/15943787

            It updates the CognitoUser with session and token JWT. Check the user object to find them, after Auth.signIn() the user Object would have updated if AWS issued tokens

            1. Does this returned credential get stored inside the mobile device? By default in android it is stored un-encrypted. Right?

            Its being stores in Shared Preferences. so yes it's on device and un-encrypted. But AWS manages updating the and changing the JWT as the user interacts with cognito automatically.

            1. Is it stored in sharedPreferences?

            Yes, it is stored in sharedPreferences

            Source https://stackoverflow.com/questions/68036388

            QUESTION

            React Native Android Duplicate class com.google.android.gms.gcm.PendingCallback found in modules jetified-firebase-jobdispatcher-0.6.0-runtime.jar
            Asked 2021-Jun-09 at 05:00

            I am facing a problem with my React Native Android project. I am currently working on integrating AWS Amplify Push Notifications. I am receiving the following "Duplicate Classes" dependency error and I don't know, where it might originate from. Do you have a solution for this problem?

            What I already did:

            • I found this ticket here https://github.com/facebook/react-native/issues/27493 which seemed to indicate that there might be an issue using react-native-device-info which was the case for me. So I removed this library and replaced it with react-native-version-info. But the problem persists.
            • I checked this ticket https://github.com/dantasfiles/AmplifyAndroidPush/issues/1 - when running ./gradlew :app:dependencies > ../dependencies.txt, I get the dependency tree and can see that com.firebase:firebase-jobdispatcher:0.6.0 seems to be solely used by aws amplify push notifications. But still I do not know what to do about this now:
            ...

            ANSWER

            Answered 2021-Jun-09 at 05:00

            Hi stackoverflow community,

            after about a week of investigating and also opening a ticket in the aws-amplify-js github project, I was now able to solve the problem. In the following, I want to describe the solution if any of you might face the same problem in the future.

            Here's the github ticket I had created on aws-amplify-js: https://github.com/aws-amplify/amplify-js/issues/8389

            In my app/build.gradle I had the following definitions related to firebase and play-services:

            Source https://stackoverflow.com/questions/67782807

            QUESTION

            Failed Cognito Federated Sign-In with Google
            Asked 2021-Jun-06 at 08:18

            I am working on a project where we have existing Google Sign-in and we would like to convert to AWS Cognito so we can get username and password authentication as well as other social logins such as Facebook in the near future. In a feature branch of our API, we have working Cognito authentication via JWT. My current issue is exchanging the Google authentication response payload for Cognito's JWT.

            In our JavaScript, I am able to get a Google authentication response object that has the tokenId field. It is my understanding that I should be able to exchange that with Cognito for their JWT that I can use for interacting with my API. I have the Google app created and configured in the Cognito User Pool.

            What has been frustrating in trying to figure this out is that all the documentation seems to focus on new apps or just on the hosted UI for Cognito. I have dug through GitHub issues and blog posts that claim this should be easy. I'm hopeful I'm missing something easy.

            For reference, here is the code I have to sign in with Cognito and extract the JWT.

            ...

            ANSWER

            Answered 2021-Jun-05 at 05:23

            QUESTION

            How to use AWS Cognito as a provider in Passport?
            Asked 2021-Apr-25 at 00:06

            I have a Javascript backend (NestJS with Express + Passport).

            I would like to outsource the complexity of authentication (e.g. social auth) to Cognito but avoid getting locked in. I was wondering if I can use Cognito as a provider in Passport, similar to social providers (Google, Facebook, etc). That way, I could integrate many providers with the effort of integrating just one. I would still manage user data, authorization, etc in my own app, therefore, if I wanted to in the future, I could implement Google, Facebook, etc. social auth in my own app and get rid of Cognito.

            If I understand it correctly this is possible with Auth0.

            Ideally, I would like to implement an OAuth flow where the user is redirected to a simple "sign up / log in" Cognito app, logs in, gets redirected to a callback URL in my app where I receive user data. If AWS doesn't host a solution for this, I can also use their UI elements to build & host this app.

            If implemented as a provider / strategy, this could be as simple as:

            ...

            ANSWER

            Answered 2021-Apr-24 at 14:30

            If you are already getting your hands dirty managing your user data I would integrate directly with the social providers. Cognito is most useful as a cheap and dirty place store user data and to host managed authentication and authorization services. You are already storing your own user data and sounds like you are only supporting social login; Cognito might be more of hindrance in this situation.

            Additonally, there isn't some magic that powers cognito social logins, you have to go through the same configuration steps if you were integrating directly, only difference is cognito will act as the callback endpoint.

            But if you want to forge ahead while avoiding vendor lock-in use it strictly as an OIDC service provider and use a generic OIDC strategy with passport or just remove passport altogether as you don't really need it in this situation, then as auth0 recommends use the oidc express middleware to protect your endpoints and use something like AppAuth to get the access token in your frontend.

            Source https://stackoverflow.com/questions/67242736

            QUESTION

            Amplify Auth.signIn() ClientMetadata not sent to Lambda Trigger
            Asked 2021-Feb-22 at 23:46

            We are moving our auth to Cognito and need to alter the token we get from Cognito. We are using a Pre Token Generation Lambda Trigger to accomplish this. We are also using Amplify's Auth library. However, I can not access the clientMetadata we are sending with Auth.signIn().

            On the front-end we simply have:

            ...

            ANSWER

            Answered 2021-Feb-22 at 23:11

            Try setting the metadata value using Auth.configure before executing Auth.signIn. On one hand, it doesn't look like the sign-in event is a pre-token lambda trigger, which explains why the metadata isn't being passed. I appreciate that this is not especially intuitive. That said, on the other hand and assuming you will need to access the same metadata value when tokens are generated as part of a refresh, you'll likely need to cover additional non-initial-signIn events anyways. Using Auth.configure looks to do the trick for both.

            Source https://stackoverflow.com/questions/66307604

            QUESTION

            Error: User is not authenticated amazon cognito in nodejs
            Asked 2021-Jan-30 at 08:57

            I am using amazon-Cognito-identity-js and aws-sdk to setup authentication in my nodeJs app.

            What i did

            First i signup using userpool.signUp(..) method according to docs. Then i confirmed the verification code using cognitoUser.confirmRegistration(..) method according to docs.

            Up to here, everything works fine. But, now i would like to get all attributes of the user. I found a method cognitoUser.getUserAttributes(..) which can give me attributes. But when i call this method after cognitoUser.confirmRegistration(..) then it returns Error: User is not authenticated.

            I went through a SO question where I got getCurrentUser() will return null at backend side.

            So, how can I authorize any user at the fully secured backend side using nodejs?

            ...

            ANSWER

            Answered 2021-Jan-30 at 08:57

            You have to first call the authenticateUser method:

            Source https://stackoverflow.com/questions/65966104

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install amplify-js

            AWS Amplify is available as aws-amplify package on npm. If you are developing a JavaScript app, please visit our documentation site on JavaScript. If you are developing a React app, please visit our documentation site on React. If you are developing an Angular app, please visit our documentation site on Angular. If you are developing a Vue app, please visit our documentation site on Vue.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries