0.0.47 • Published 10 months ago

@locii/universal-login-sdk v0.0.47

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

Cognito MFA Package

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

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 = {
  ClientId: '',
  UserPoolId: '',
  ClientMetadata: { redirectURI: 'http://localhost:3000/login' },
  Auth: {
    region: '',
    userPoolId: '',
    userPoolWebClientId: '',
    authenticationFlowType: 'CUSTOM_AUTH'
  }
};

ClientId: Biopass Client ID

UserPoolId: Cognito user pool ID

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.

userPoolWebClientId: Cognito Client ID

Step 2:

import { Amplify } from 'aws-amplify';
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, config.ClientMetadata)
        .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, configClientMetadata)
        .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, config.ClientMetadata)
          .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.45

10 months ago

0.0.46

10 months ago

0.0.47

10 months ago

0.0.40

10 months ago

0.0.41

10 months ago

0.0.42

10 months ago

0.0.43

10 months ago

0.0.44

10 months ago

0.0.38

10 months ago

0.0.39

10 months ago

0.0.37

10 months ago

0.0.36

10 months ago

0.0.35

10 months ago

0.0.34

10 months ago

0.0.33

10 months ago

0.0.32

10 months ago

0.0.31

10 months ago

0.0.30

10 months ago

0.0.29

10 months ago

0.0.28

10 months ago

0.0.27

10 months ago

0.0.26

10 months ago

0.0.25

10 months ago

0.0.24

11 months ago

0.0.23

11 months ago

0.0.22

11 months ago

0.0.21

11 months ago

0.0.20

11 months ago

0.0.19

11 months ago

0.0.18

11 months ago

0.0.17

11 months ago

0.0.16

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago

0.0.4

11 months ago