Giter Club home page Giter Club logo

aws-cognito-wrapper's Introduction

Amazon Cognito Identity SDK for JavaScript Wrapper

Build status: N|Solid

Interacting with the existing Amazon Cognito Identity SDK for JavaScript proved a little painful - you had to do a lot of plumbing to do to perform simple tasks, which normally meant you had to wrap the SDK code in a repository of some sort to simplify things. (Not to mention that if you use automated tests at all, you'd need to write tests for all of this code).

In order to make things easier on myself (and others) - I've wrapped the logic most often used in the SDK, which now only requires you to include the wrapper which will perform all the plumbing for you, only requiring you to send through a few parameters for each method.

Right now, not all methods are wrapped, but feel free to submit a pull request for any new wrapped methods.

User attributes

User attributes can be passed to the methods in the following format:

[
    {
        name: 'Some Attribute Name',
        value: 'Some Attribute Value
    },
    {
        name: 'Another Attribute Name',
        value: 'Another Attribute Value
    }
}

User functions

Authenticate a user

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.auth(username, password, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

Create a user

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.create(username, password, userPoolId, clientId, attributes)
    .then(// Handle result here)
    .catch(// Handle exception here);

See the User attributes section for the expected format of the attributes parameter.

Confirm user registration

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.confirmRegistration(username, confirmationCode, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

Resend user confirmation code

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.resendConfirmationCode(username, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

Get user attributes

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.getAttributes(username, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

Delete user attributes

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.deleteAttributes(username, attributeNames, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

The attributeNames parameter is simply an array of the attribute names.

Update user attributes

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.updateAttributes(username, attributes, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

See the User attributes section for the expected format of the attributes parameter.

Change user password

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.changePassword(username, oldPassword, newPassword, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

Send forgot password notification

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.forgotPassword(username, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

Remove a user

const cognito = require('aws-cognito-wrapper');
wrapper.UserService.remove(username, userPoolId, clientId)
    .then(// Handle result here)
    .catch(// Handle exception here);

aws-cognito-wrapper's People

Contributors

charltruter avatar

Stargazers

Adam Koewler avatar Sean Dwyer avatar Rashmi V Abbigeri avatar  avatar Hugo Barbosa avatar Aleks Obrazcova avatar  avatar

Watchers

James Cloos avatar

aws-cognito-wrapper's Issues

Question about your script

I'm new to Cognito... Can this script be called from a regular HTML file hosted / stored on a web enabled bucket?

Thanks

Hugo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.