npm install peer-identity
const PeerIdentity = require('peer-identity');
const peerIdentity = new PeerIdentity();
Use the ignore plugin to ignore node-localstorage
and node-webcrypto-ossl
when building for the browser.
new PeerIdentity({
localStoragePath: '/tmp/myLocalStorage'
});
Config Options:
- localStoragePath: file to usage for
node-localstorage
if using node rather than browser
Generates signing keys. Stores in this.sesssion.publicKey
and this.session.privateKey
returns Promise(keyPair)
const keyPair = await peerIdentity.generateSessionKeys();
Loads signing keys from localStorage.
returns Promise(bool)
const loaded = await peerIdentity.loadFromLocalStorage();
Saves current signing keys to localStorage.
returns Promise(bool)
const saved = await peerIdentity.saveToLocalStorage();
Adds a peer session to be used by verify functions.
arguments:
- id string session/did id
- jwk json string or object
returns Promise(bool)
const added = await peerIdentity.addSession('id:lkajdsflkjasdf', jwk);
Signs data with the session signing keys.
arguments:
- data string or json object
returns Promise(\
${Base58(data)}.${Base58(id)}.sig`)`
Verifies signature and decodes data.
arguments:
- data and sig in form:
${Base58(data)}.${Base58(id)}.sig
returns ```js
Promise({
data, //decoded base58
id, // decoded base58
sig,
error, // including "SESSION_NOT_FOUND"
})
### exportDID
TODO
### loadPeerFromDID
TODO