Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

muport-core

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

muport-core

Create and use µPort identities

  • 0.3.0-beta-2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by750%
Maintainers
2
Weekly downloads
 
Created
Source

µPort core

CircleCI codecov

This library is intended to be used to create, update, and recover µPort identities, as well as using the identity to sign and encrypt data.

Usage

Simply install using npm

$ npm install muport-core

and then import into your project

const MuPort = require('muport-core')

MuPort

Primary object for interacting with a µPort identity. MuPort enables creation and updating of µPort identities. It also provides functionality to sign claims and help other identities recover.

Kind: global class

new MuPort(serializeState, [opts])

Instantiates a µPort identity from its serialized state.

ParamTypeDescription
serializeStateStringthe serialized state of a µPort identity
[opts]Objectoptional parameters
opts.ipfsConfObjectconfiguration options for ipfs-mini
opts.rpcProviderUrlStringrpc url to a custom ethereum node

muPort.helpRecover(did) ⇒ Promise.<String, Error>

Help another identity recover. Returns a decrypted share if the current identity is a delegate returns undefined otherwise

Kind: instance method of MuPort
Returns: Promise.<String, Error> - a share that the recovering identity can use

ParamTypeDescription
didStringthe did of the identity that should be recovered

muPort.getDid() ⇒ String

The DID is the identifier of the identity. This is a unique string that can be used to look up information about the identity.

Kind: instance method of MuPort
Returns: String - the DID

muPort.getDidDocument() ⇒ Object

The DID Document is a json object that contains information such as public keys

Kind: instance method of MuPort
Returns: Object - the DID Document

muPort.getRecoveryDelegateDids() ⇒ Array.<String>

The recovery delegates that can help this identity recover

Kind: instance method of MuPort
Returns: Array.<String> - an array containing the DIDs of the delegates

muPort.updateIdentity(publicProfile, delegateDids) ⇒ Promise.<Object, Error>

This function is used to update the publicProfile and/or the recoveryNetwork of the identity. The returned object has three properties; address an ethereum address, costInEther a number, and finishUpdate a function. In order to complete the update of the delegates you have to send costInEther ether to the address on mainnet (or other network if you are using a custom config). Once that is done the finishUpdate function can be called. This function sends a transaction to the network that updates the identity. The function will throw an error if there is to little ether in the address. Both publicProfile and delegateDids are optional and you may pass null if you don't wish to update one of them.

Kind: instance method of MuPort
Returns: Promise.<Object, Error> - an object with the data needed to finalize the update

ParamTypeDescription
publicProfileObjecta new public profile for the identity
delegateDidsArray.<String>an array containing the 3 DIDs of the new delegates

muPort.signJWT() ⇒ Promise.<String, Error>

Signs the given payload (claim) and return a promis with the JWT.

Kind: instance method of MuPort
Returns: Promise.<String, Error> - a promise that resolves to a JWT

muPort.verifyJWT(jwt, audience) ⇒ Promise.<Object, Error>

Verifies a JWT.

Kind: instance method of MuPort
Returns: Promise.<Object, Error> - a promise that resolves to the decoded JWT

ParamTypeDefaultDescription
jwtStringthe JWT to verify
audienceStringthis.didthe audience, defaults to did of current identity

muPort.serializeState() ⇒ String

Serialize the state of the current identity to be able to reconstruct it later.

Kind: instance method of MuPort
Returns: String - the serialized state

MuPort.newIdentity(publicProfile, delegateDids, [opts]) ⇒ Promise.<MuPort, Error>

Creates a new µPort identity.

Kind: static method of MuPort
Returns: Promise.<MuPort, Error> - a promise that resolves to an instance of the MuPort class

ParamTypeDescription
publicProfileObjecta public profile for the new identity
delegateDidsArray.<String>three DIDs that can be used to recover the identity at a later point (optional)
[opts]Objectoptional parameters
opts.externalMgmtKeyStringan ethereum address to be used as an external managementKey
opts.ipfsConfObjectconfiguration options for ipfs-mini
opts.rpcProviderUrlStringrpc url to a custom ethereum node

MuPort.recoverIdentity(did, shares, [opts]) ⇒ Promise.<MuPort, Error>

Recovers a µPort identity.

Kind: static method of MuPort
Returns: Promise.<MuPort, Error> - a promise that resolves to an instance of the MuPort class

ParamTypeDescription
didStringthe DID of the identity to be recovered
sharesArray.<String>atleast two shares that your delegates helped recover
[opts]Objectoptional parameters
opts.ipfsConfObjectconfiguration options for ipfs-mini
opts.rpcProviderUrlStringrpc url to a custom ethereum node

MuPort.resolveIdentityDocument(did, [opts]) ⇒ Promise.<Object, Error>

Resovles the identity document for the given DID.

Kind: static method of MuPort
Returns: Promise.<Object, Error> - a promise that resolves to the identity document

ParamTypeDescription
didStringthe DID of the identity
[opts]Objectoptional parameters
opts.ipfsConfObjectconfiguration options for ipfs-mini
opts.rpcProviderUrlStringrpc url to a custom ethereum node

FAQs

Package last updated on 09 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc