Skip to content

DivvyDAO/uport-sso.js

 
 

Repository files navigation

uport-sso.js

Version npm Build Status Dependency Status Dev Dependency Status Documentation Status

NPM

uPort single sign-on js library provides an API for registering, storing and retrieving lightwallet backups from the keystore server.

Installation

$ npm install --save uport-sso.js

Usage

import uPortSSO from 'uport-sso.js';

const identity = new uPortSSO();
// or
const identity = new uPortSSO({
  url: `https://sso.uport.me/api/v1/keystore`,
  email: `email@example.com`, // You can pass a default email address
  token: `authentication_token`, // You can pass an authentication token
  confirmPath: `https://uport.me/verify/account`, // You can pass the url for the confirmation link sent via email
});

Methods

All methods return the response as promises.

identity.register(email, password)
  .then(result => {
    console.log(result);
  })
  .catch(err => {
    console.error(error);
  });

Register

Register a new account.

identity.register(email, password);

If successful, it will return:

{
  status: `success`,
  message: `A confirmation e-mail has been sent. Please confirm your e-mail address.`,
}

Confirm e-mail address

Confirm the e-mail address with the token received.

identity.confirm(confirmationToken);

If successful, it will return:

{
  status: `success`,
  message: `Your account has been verified.`,
  id: 82183151,
  keystore: null,
  verified: true,
}

Resend e-mail validation token

Resend an email containing the validation token.

identity.resend(email);

If successful, it will return:

{
  status: `success`,
  message: `A confirmation e-mail has been sent. Please confirm your e-mail address.`,
}

Sign in

Sign in an account to get the authentication token

identity.login(email, password);

If successful, it will return:

{
  status: `success`,
  token: `authenticationToken`,
  id: 82183151,
  keystore: null,
  verified: true,
}

Get keystore

If authenticated, get the keystore

identity.get(token);

If successful, it will return:

{
  status: `success`,
  id: 82183151,
  keystore: {},
  verified: true,
}

Collect entropy

Collect entropy on mousemove/touchmove or keyboard input.

identity.collectEntropy(window, progressCallback, endCallback);

Progress callback will return the percentage of collected entropy

function progressCallback(progress) {
  console.log(progress); // > 58
}

End callback will return the entropy string

function endCallback(entropy) {
  console.log(entropy); // > entropy string
}

Generate Seed

Generate the 12 word mnemonic seed.

const seed = identity.generateSeed(entropy);
console.log(seed)
// myth asthma can fitness video meat wash kitten salute enable unusual dune

Generate keystore

Generate a keystore.

identity.generate(token, password, seed, entropy);

If successful, it will return:

{
  status: `success`,
  message: `Keystore updated.`,
  id: 82183151,
  keystore: { object },
  verified: true,
}

Migrate keystore

Recover a keystore using a predefined seed

identity.migrate(token, password, seed);

If successful, it will return:

{
  status: `success`,
  message: `Keystore updated.`,
  id: 82183151,
  keystore: { object },
  verified: true,
}

Remove account

Remove account from keyserver.

identity.remove(token);

If successful, it will return:

{
  status: `success`,
  message: `Account deleted.`,
}

Fuel account

Submit a code in order to fund the account.

identity.fuel(token, code);

If successful, it will return:

{
  status: `success`,
  message: `Account funded.`
}

Packages

No packages published

Languages

  • JavaScript 100.0%