All Projects → AirLabsTeam → React Native Aws Cognito Js

AirLabsTeam / React Native Aws Cognito Js

Licence: other
React Native AWS Cognito JS SDK

Programming Languages

javascript
184084 projects - #8 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to React Native Aws Cognito Js

Awsmobile Cli
CLI experience for Frontend developers in the JavaScript ecosystem.
Stars: ✭ 147 (+9.7%)
Mutual labels:  aws, aws-cognito
Auth Api Demo
Securing Microservices on AWS with Cognito, API Gateway and Lambda Demo
Stars: ✭ 140 (+4.48%)
Mutual labels:  aws, aws-cognito
Cognito Backup Restore
AIO Tool for backing up and restoring AWS Cognito User Pools
Stars: ✭ 142 (+5.97%)
Mutual labels:  aws, aws-cognito
Cognito Express
Authenticates API requests on a Node application by verifying the JWT signature of AccessToken or IDToken generated by Amazon Cognito.
Stars: ✭ 165 (+23.13%)
Mutual labels:  aws, aws-cognito
Aws Serverless Auth Reference App
Serverless reference app and backend API, showcasing authentication and authorization patterns using Amazon Cognito, Amazon API Gateway, AWS Lambda, and AWS IAM.
Stars: ✭ 724 (+440.3%)
Mutual labels:  aws, aws-cognito
Amazon Cognito Identity Js
Amazon Cognito Identity SDK for JavaScript
Stars: ✭ 965 (+620.15%)
Mutual labels:  aws, aws-cognito
Serverless Aws Cognito Login
Simple example project with instructions how to implement serverless login using AWS Cognito.
Stars: ✭ 26 (-80.6%)
Mutual labels:  aws, aws-cognito
Amplify Js
A declarative JavaScript library for application development using cloud services.
Stars: ✭ 8,539 (+6272.39%)
Mutual labels:  aws, aws-cognito
Kaws
Create and manage Kubernetes clusters on AWS using Terraform.
Stars: ✭ 129 (-3.73%)
Mutual labels:  aws
Aws Launcher
AWS Launcher. Launch AWS Services from your macOS dock.
Stars: ✭ 132 (-1.49%)
Mutual labels:  aws
Kumogata
Kumogata is a tool for AWS CloudFormation. It can define a template in Ruby DSL.
Stars: ✭ 128 (-4.48%)
Mutual labels:  aws
Terraform Aws S3 Bucket
Terraform module which creates S3 bucket resources on AWS
Stars: ✭ 130 (-2.99%)
Mutual labels:  aws
Aws Codebuild Jenkins Plugin
AWS CodeBuild integration as a Jenkins build step.
Stars: ✭ 132 (-1.49%)
Mutual labels:  aws
Vscode Deploy Reloaded
Recoded version of Visual Studio Code extension 'vs-deploy', which provides commands to deploy files to one or more destinations.
Stars: ✭ 129 (-3.73%)
Mutual labels:  aws
Aws Maintenance Lambda
A lambda function to send alerts (to Slack, HipChat) on AWS maintenance events.
Stars: ✭ 133 (-0.75%)
Mutual labels:  aws
Aws Iam Authenticator
A tool to use AWS IAM credentials to authenticate to a Kubernetes cluster
Stars: ✭ 1,713 (+1178.36%)
Mutual labels:  aws
Aws Secrets Manager Rotation Lambdas
Contains Lambda functions to be used for automatic rotation of secrets stored in AWS Secrets Manager
Stars: ✭ 128 (-4.48%)
Mutual labels:  aws
Kube2iam
kube2iam provides different AWS IAM roles for pods running on Kubernetes
Stars: ✭ 1,774 (+1223.88%)
Mutual labels:  aws
Dynamo Easy
DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
Stars: ✭ 133 (-0.75%)
Mutual labels:  aws
Terraform Aws Vpc
Terraform Module that defines a VPC with public/private subnets across multiple AZs with Internet Gateways
Stars: ✭ 130 (-2.99%)
Mutual labels:  aws

This library is deprecated. It was merged into aws cognito identity js and finally into:

https://github.com/aws-amplify/amplify-js.

The amplify library will have the most up to date versions of everything and is maintained by AWS.

react-native-aws-cognito-js npm version

This is an adaptation of Amazon Cognito Identity SDK for JavaScript in combination with AWS SDK for JavaScript for React Native.

This project uses Native Modules to handle intensive math operations on the device using the React Native bridge.

Installation

Install in your application directory:

npm install --save react-native-aws-cognito-js

or

yarn add react-native-aws-cognito-js

Link project:

react-native link react-native-aws-cognito-js

MemoryStorage

The local MemoryStorage can handle everything on the authentication side, but the data is lost when the app is reopened. The storage sync method will grab only the MemoryStorage data from AsyncStorage and update the local MemoryStage with the values.

The new sync method can be used from either the userPool or cognitoUser:

userPool.storage.sync((err, result) => {
  // MemoryStorage is now updated with AsyncStorage values
});

or

cognitoUser.storage.sync((err, result) => {
  // MemoryStorage is now updated with AsyncStorage values
});

Usage

Refer to the Amazon Cognito Identity SDK for JavaScript usage examples.

Example

This is a user authentication sample:

//imports
import {
  Config,
  CognitoIdentityCredentials
} from 'aws-sdk/dist/aws-sdk-react-native';

import {
  AuthenticationDetails,
  CognitoUser,
  CognitoUserPool,
  CognitoUserAttribute
} from 'react-native-aws-cognito-js';

const appConfig = {
  region: '',
  IdentityPoolId: '',
  UserPoolId: '',
  ClientId: '',
}

//setting config
Config.region = appConfig.region;

//component:
state = {
  username: '',
  password: '',
}

login = () => {
  const { username, password } = this.state;
  const authenticationData = {
    Username: username,
    Password: password,
  };
  const authenticationDetails = new AuthenticationDetails(authenticationData);
  const poolData = {
    UserPoolId: appConfig.UserPoolId,
    ClientId: appConfig.ClientId
  };
  const userPool = new CognitoUserPool(poolData);
  const userData = {
    Username: username,
    Pool: userPool
  };
  const cognitoUser = new CognitoUser(userData);
  cognitoUser.authenticateUser(authenticationDetails, {
    onSuccess: (result) => {
      console.log('access token + ' + result.getAccessToken().getJwtToken());
      Config.credentials = new CognitoIdentityCredentials({
        IdentityPoolId: appConfig.IdentityPoolId,
        Logins: {
          [`cognito-idp.${appConfig.region}.amazonaws.com/${appConfig.UserPoolId}`]: result.getIdToken().getJwtToken()
        }
      });
      alert('Success');
      console.log(Config.credentials);
    },
    onFailure: (err) => {
      alert(err);
    },
  });
}

Advanced Example

//- AWS.js
//create AWS with userPool using dotenv to hold environment variables
import AWS, { CognitoIdentityServiceProvider } from 'aws-sdk/dist/aws-sdk-react-native';
import * as enhancements from 'react-native-aws-cognito-js';
import { AWS_REGION, AWS_POOL_ID, AWS_POOL_CLIENT_ID } from 'react-native-dotenv';

Object.keys(enhancements).forEach(key => (CognitoIdentityServiceProvider[key] = enhancements[key]));

AWS.config.update({ region: AWS_REGION });

export const poolData = {
  UserPoolId: AWS_POOL_ID,
  ClientId: AWS_POOL_CLIENT_ID,
};

export const userPool = new AWS.CognitoIdentityServiceProvider.CognitoUserPool(poolData);

export default AWS;
//import AWS and userPool
import AWS, { userPool } from './AWS';

//component:
state = {
  username: '',
  password: '',
}

login = () => {
  const { username, password } = this.state;
  const authenticationData = { Username: username, Password: password };
  const authenticationDetails = new AWS.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
  const userData = { Username: username, Pool: userPool };
  const cognitoUser = new AWS.CognitoIdentityServiceProvider.CognitoUser(userData);
  cognitoUser.authenticateUser(authenticationDetails, {
    onSuccess: (result) => {
      console.log('result', result);
      console.log('access token:', result.getAccessToken().getJwtToken());
    },
    onFailure: (error) => {
      Alert.alert(error.code, error.message);
    },
  });
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].