GithubHelp home page GithubHelp logo

uauth's Introduction

@uauth/js

Installation

yarn add @uauth/js @unstoppabledomains/resolution

Setup

import UAuth from '@uauth/js'

const uauth = new UAuth({
  // Client credentials copied from https://unstoppabledomains.com/app-dashboard
  clientID: process.env.UAUTH_CLIENT_ID!,
  clientSecret: process.env.UAUTH_CLIENT_SECRET!,

  // Requested scopes.
  scope: 'openid email wallet',

  // Redirect Uris copied from https://unstoppabledomains.com/app-dashboard
  redirectUri: process.env.UAUTH_REDIRECT_URI!,
  postLogoutRedirectUri: process.env.UAUTH_POST_LOGOUT_REDIRECT_URI!,
})

Referals

If you have a referal link you can configure the library to use that referal link on the Get a Domain link on the bottom right of the modal by configuring the following setting.

const uauth = new UAuth({
  // Other options...
  uiOptions: {
    getADomainLink: "https://unstoppabledomains.com/?ref=my_referal_code"
  }
})

Methods

uauth.login()

  1. Exposes modal to allow users to select domain.
  2. Queries the blockchain to find if an auth server has been configured otherwise uses fallback.
  3. Redirects the user to the auth server with a OIDC compliant authorization request.
  4. After every authorization attempt the server will redirect the user to the redirectUri specified at instanciation.

uauth.loginCallback()

  1. Parses authorization code found in current uri.
  2. Exchanges authorization code for access and id tokens.
  3. Stores authorization (id and access tokens) inside cache, the default cache is window.localStorage.

uauth.logout()

  1. Uses cached authorization to create a logout uri.
  2. Redirects to that uri.
  3. After every logout attempt the server will redirect the user to the postLogoutRedirectUri specified at instanciation.

uauth.user()

  1. Returns the cached data about the user as long as it's still valid.

uauth's People

Contributors

alonnftrade avatar

Watchers

Shahaf avatar Maor Davidov 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.