Giter Club home page Giter Club logo

identifo.js's Introduction

Identifo.js

License: MIT

https://nodei.co/npm/@identifo/identifo-auth-js.png?downloads=true&downloadRank=true&stars=true

Browser library for authentication through Identifo.

Install

# Run this command in your project root folder.
# yarn
$ yarn add @identifo/identifo-auth-js

# npm
$ npm install @identifo/identifo-auth-js

Usage

Initialize

  import IdentifoAuth from '@identifo/identifo-auth-js';

  const identifo = new IdentifoAuth({
    url: 'http://localhost:8081', // URI of your Identifo server.
    appId: 'your app ID', // ID of application that you want to get access to.
  });

Parametrs

All parameters can be considered optional unless otherwise stated.

Option Type Description
url string (required) The url of your Identifo server.
appId string (required) ID of application that you want to get access to.
issuer string The issuer claim identifies the principal that issued the JWT.
scopes string [] The default scopes used for all authorization requests.
redirectUri string The URL where Identifo will call back to with the result of a successful authentication. It must be added to the "Redirect URLs" in your Identifo Application's settings.
postLogoutRedirectUri string The URL where Identifo will call back to after a successful log-out. It must be added to the "Redirect URLs" in your Identifo Application's settings.
tokenManager TokenManager instance The tokenManager provides access to client storage for specific purposes
autoRenew boolean Renew tokens before they expire. By default autoRenew is false.

API

init()

Method which initialize your identifo instance and actualize your states. Call it before other methods.

handleAuthentication():Promise

Processing the received token. Call it on the redirect page to handle and verify token.

renewSession():Promise

Allows you to renew session manually. Returns new JWT.

identifo.renewSession().then((token) => {})

signin()

Redirect user to sign-in page. After successful sign-in you will be redirected to redirectUri

signup()

Redirect user to sign-up page. After successful sign-up you will be redirected to redirectUri

logout()

Logout and redirects back to postLogoutRedirectUri the user out of their current Identifo session and clears all tokens stored locally in the TokenManager. By default, the refresh token (if any) and access token are revoked so they can no longer be used.

getToken()

Returns token and token payload

{ token: 'JWT', payload: 'JWT payload' }

TokenManager

import IdentifoAuth, { SessionStorageManager } from '@identifo/identifo-auth-js';

const identifo = new IdentifoAuth({
    appId: 'your app ID',
    url: 'http://localhost:8081',
    tokenManager: new SessionStorageManager() // you can pass your custom key for storage. Bt default it`s identifo_access_token
  })

You can import SessionStorageManager | LocalStorageManager. By default it`s LocalStorageManager.

isAuth:boolean

Returns actual auth statis of the user.

const isAuth = identifo.isAuth;

redirectUri

The url that is redirected to when using identifo.signin or identifo signup methods. This must be listed in your Identifo application's redirect URLs. If no redirectUri is provided, defaults to the current url (window.location.href).

postLogoutRedirectUri

The url that is redirected to when using identifo.logout method. This must be listed in your Identifo application's redirect URLs. If not specified, user will be redirected to login page.

Author

madappgang

License

This project is licensed under the MIT license. See the LICENSE file for more info.

identifo.js's People

Contributors

nikita-ks avatar erudenko avatar sokolovstas avatar

Watchers

James Cloos avatar  avatar

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.