0.0.37 • Published 11 months ago

@locii/biopass-cognito-sdk v0.0.37

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

Cognito MFA Package

This SDK is a wrapper for adding Biopass Multifactor authentications to applications which had their users in AWS Cognito.

Table of Contents

Getting Started

Use React App

Use Angular App

Use Vue App

Getting Started

Install the package

  npm install @locii/biopass-cognito-sdk

Require the package

To import @locii/biopass-cognito-sdk, run the following command

import { BiopassAuth } from "@locii/biopass-cognito-sdk";

After installing the packege, do the following steps:

Step 1: Create config file

export const config = {
  Auth: {
    region: '',
    userPoolId: '',
    userPoolWebClientId: '',
    authenticationFlowType: 'CUSTOM_AUTH',
    clientMetadata: { redirectUri: 'http://localhost:3000/login' },
  }
};

redirectUri: The user is redirected to this address after authentication. Please make sure this is exactly same as the Allowed Callback URL setting in Biopass application.

Step 2:

import { Amplify } from 'aws-amplify';
    "@aws-amplify/ui-angular": "^3.2.10",
import * as ui from '@aws-amplify/ui-angular';
import config from './amplify-config';
Amplify.configure(config);

Use React App

When signing in with user name and password, you will pass in the username and the password to the signin method of the Auth class.

Sign-In

import { BiopassAuth } from "@locii/biopass-cognito-sdk";

const login = async (event) => {
      BiopassAuth.signin(username, password)
        .then((res) => {
          // add your code
        })
        .catch((err) => // add your code);
  };

  useEffect(() => {
    BiopassAuth.resumeSignIn()
      .then((user) => {
       // add your code
      })
      .catch((err) => {
       // add your code
      });

  }, []);

Sign-Out

import { Auth } from 'aws-amplify';

async function signOut() {
    try {
        await Auth.signOut();
    } catch (error) {
        console.log('error signing out: ', error);
    }
}

Use Angular App

When signing in with user name and password, you will pass in the username and the password to the signin method of the Auth class.

Global config

Add a below command in Ployfills.ts

(window as any).global = window;

Sign-In

import { BiopassAuth } from "@locii/biopass-cognito-sdk";

  ngOnInit() {
    your code ...
    BiopassAuth.resumeSignIn()
      .then((user) => {
        console.log('userr', user);
        // add your code
      })
      .catch((err) => {
        // add your code
      });
  }

  login() {
      BiopassAuth.signin(this.username.value, this.password.value)
        .then((res) => {
          // add your code
        })
        .catch((err) => // add your code);
  }

Sign-Out

import { Auth } from 'aws-amplify';

  logout() {
    try {
      Auth.signOut();
    } catch (error) {
      console.log('error signing out: ', error);
    }
  }

Use Vue App

When signing in with user name and password, you will pass in the username and the password to the signin method of the Auth class.

Global config

Add a below command in App.vue

var global = window

Sign-In

import { BiopassAuth } from "@locii/biopass-cognito-sdk";

  created() {
    BiopassAuth.resumeSignIn()
      .then((user) => {
        // add your code
      })
      .catch((err) => {
        // add your code
      })
  },
  methods: {

    login() {
      //add your code

        BiopassAuth.signin(this.username, this.password)
          .then((res) => {
            // add your code
          })
          .catch((err) => console.log('asasasas'))
    }
  }

Sign-Out

import { Auth } from 'aws-amplify';

  logout() {
    try {
      Auth.signOut();
    } catch (error) {
      console.log('error signing out: ', error);
    }
  }
0.0.40

10 months ago

1.0.0

10 months ago

0.0.38

10 months ago

0.0.39

10 months ago

0.0.37

11 months ago

0.0.34

11 months ago

0.0.35

11 months ago

0.0.36

11 months ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago