uPort single sign-on js library provides an API for registering, storing and retrieving lightwallet backups from the keystore server.
$ npm install --save uport-sso.js
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
});
All methods return the response as promises.
identity.register(email, password)
.then(result => {
console.log(result);
})
.catch(err => {
console.error(error);
});
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 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 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 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,
}
If authenticated, get the keystore
identity.get(token);
If successful, it will return:
{
status: `success`,
id: 82183151,
keystore: {},
verified: true,
}
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 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 a keystore.
identity.generate(token, password, seed, entropy);
If successful, it will return:
{
status: `success`,
message: `Keystore updated.`,
id: 82183151,
keystore: { object },
verified: true,
}
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 from keyserver.
identity.remove(token);
If successful, it will return:
{
status: `success`,
message: `Account deleted.`,
}
Submit a code in order to fund the account.
identity.fuel(token, code);
If successful, it will return:
{
status: `success`,
message: `Account funded.`
}