Seraph ID JavaScript SDK.
Overview
This is the JavaScript SDK for Seraph ID - a self-sovereign identity solution on the NEO blockchain platform. This project aims to be a lightweight and simple helper to use Seraph ID wallets, claims issuance and verification in the browser.
Visit the Seraph ID official web page to learn more about self-sovereign identity!
Getting started
Installation
Node.js
npm i @sbc/seraph-id-sdk --save
Usage
Node.js
var seraphId = ;
Seraph ID Owner
Create a new wallet:
var wallet = name: 'MyWallet' ;
Generate a new DID (here for private network):
var myDID = wallet; // e.g. did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs
Add a claim issued by Seraph ID issuer:
wallet;
Encrypt and export wallet:
wallet;var exportedWalletJson = wallet;
Import wallet, decrypt it and get all claims of a specified DID or a claim by ID:
var wallet = exportedWalletJson;wallet; var allClaims = wallet;var claim = wallet;
Seraph ID Issuer
Create issuer instance:
var issuer = 'issuerSmartContractScriptHash' 'http://localhost:10332' 'http://localhost:4000/api/main_net' DIDNetworkPrivateNet;
Create a new (revokable) credentials schema:
issuer;
Create and issue a claim:
var claim = issuer; issuer;
Revoke previously issued claim (if schema allows revocation):
issuer;
Seraph ID Verifier
Create verifier instance:
var verifier = 'issuerSmartContractScriptHash' 'http://localhost:10332' 'http://localhost:4000/api/main_net' DIDNetworkPrivateNet;
Get meta-data of issuer's credentials schema:
var schema = verifier;
Verify the given owner's claim offline (having issuer's public key):
var verfied = verifier;
Verify the given owner's claim online (calling issuer's smart contract):
var verfied = verifier;
Validate the given owner's claim. Validation includes online verification, claim revocation and validity dates check. Optionally custom validation function can be passed.
var valid = verifier;
Check if issuer of owner's claim is trusted by the given Root of Trust:
var trusted = verifier;
Seraph ID Root of Trust
Create Root of Trust instance:
var rot = 'rotSmartContractScriptHash' 'http://localhost:10332' 'http://localhost:4000/api/main_net' DIDNetworkPrivateNet;
Register issuer's DID and schema as trusted:
rot;
Remove trust for issuer's DID and schema from RoT:
rot;
Check if issuer is trusted with the given schema:
var trusted = rot;
Contributing
Setup
This repository is a typescript repository using Yarn. Please ensure the following is installed:
- Yarn (v 1.16.0 or higher)
- Node (latest LTS)
git clone https://github.com/swisscom-blockchain/seraph-id-sdk.gitcd seraph-id-sdkyarnyarn build
Testing
Before executing unit tests, please make sure to have:
- Issuer's smart contract deployed on your network.
- Network information and test data maintained properly in
__tests__/test-data.json
file.
yarn test
References
- Seraph ID official page: https://seraphid.io
- Seraph ID demo application on GitHub
- Seraph ID smart contract templates and examples on GitHub
- Seraph ID chrome extension GitHub
- Seraph ID DID resolver on GitHub
License
- Open-source MIT.