2.2.3 • Published 5 months ago

@dataobservatory/cognito-auth v2.2.3

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Data Observatory's Cognito Auth

 

Description:

This library uses the AWS Cognito SDK and covers the following cases:

  • User Registration
  • Confirmation of registered users.
  • Forwarding of registration confirmation codes.
  • User authentication with AWS Cognito.
  • Password recovery flow.
  • Change of password.
  • Log out.

Each of the operations described above allows you to manipulate both the error and success return values with a handler callback function.

 

Conventions used:

Objects and it's properties and methods are named in PascalCase.

Types and Interfaces are named in PascalCase.

Method Parameters are named in camelCase.

Decisions were made based on Cognito's SDK.

 

Usage:

At the main HTML file, add teh following script tag:

<script> window.global = window; </script>

Otherwise, the library might not work as expected.

// Instantiate a cognitoAuth object:
const auth = new CognitoAuth();

// User attributes for sign in.
const username = "john.doe@email.com";
const password = "Password1!";
const attributes = [{ Name: "email", Value: username }];

// Response handler
const handler = (error?: Error, result?: unknown) => {
  if (error) console.error(error);
  else if (result) console.log(JSON.stringify(result));
}

// Register a new user:
auth.SignUp(
  username,
  password,
  attributes,
  handler
);

// Enable automatic sign in using:
auth.CachedSignIn(handler);

// Manual sign in
auth.SignIn(username, password, handler);

// Sign out invalidating user's token (recommended)
auth.SignOut(true, handler);
2.2.3

5 months ago

2.1.3

6 months ago

2.0.3

11 months ago

2.0.2

1 year ago

2.0.1

1 year ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago