Giter VIP home page Giter VIP logo

login's Introduction

Available Scripts

Description

GetLogin implements an OpenID Connect authentication through OAuth 2 (implicit flow - client-side only).

Last project build hosted at getlogin.eth.

ETHCC2020 - Daniel Nagy: "Decentralized User Account Management"

Register your app in GetLogin smart contract

  1. Get last contract address from url: https://swarm-gateways.net/bzz:/getlogin.eth/xsettings

  2. Register as user with method createUser(usernameHash) where usernameHash is keccak256 hash of your username. Or pass if you already registered.

  3. Register application with method createApplication. Store application id which will return this method.

  4. Add allowed application urls (urls where your app is hosted) with addApplicationUrl

Inject GetLogin to your dApp

Add <script async src="https://swarm-gateways.net/bzz:/getlogin.eth/api/last.js"></script> to <head>

Init:

window.getLoginApi.init(appId, 'https://swarm-gateways.net/bzz:/getlogin.eth/', redirectUrl)
.then(data => {
    console.log(data);
});

where appId is your app id stored in step 3 of registration app instruction, redirectUrl is your app url.

Call methods: window.getLoginApi.getUserInfo().then(data => alert(JSON.stringify(data))).catch(e => alert(e));

Call dApp contract methods

Set contract ABI: window.getLoginApi.setClientAbi(abi);

Call getNotes method which defined in your dapp contract:

window.getLoginApi.callContractMethod(address, 'getNotes', usernameHash)
.then(data => {
    console.log(data);
})
.catch(e => {
    console.log(e);
});

address is your dapp address

Send transaction to your dapp contract:

window.getLoginApi.sendTransaction(address, 'createNote', noteText, {resolveMethod: 'mined'})
.then(data => {
    console.log(data);
})
.catch(e => {
    console.log(e);
});

address is your dapp address

createNote is your dapp method defined in contract

One important param is resolveMethod. Values of this param can be:

'mined' - fired when tx sent and mined (slow)

'transactionHash' - when tx sent (fast)

Building project

In the project directory, you can run:

yarn - install dependencies

yarn build - build project

yarn start - start project locally

login's People

Contributors

igorshadurin avatar graomelo avatar dependabot[bot] avatar margarita-sh avatar snyk-bot avatar

Stargazers

 avatar

Watchers

James Cloos 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.