npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@justin_jin/seraph-id-sdk

v3.0.1

Published

Seraph ID SDK

Downloads

3

Readme

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 = require('@sbc/seraph-id-sdk');

Seraph ID Owner

Create a new wallet:

var wallet = new seraphId.SeraphIDWallet({ name: 'MyWallet' });

Generate a new DID (here for private network):

var myDID = wallet.createDID(DIDNetwork.PrivateNet); // e.g. did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs

Add a claim issued by Seraph ID issuer:

wallet.addClaim(claim);

Encrypt and export wallet:

wallet.encryptAll('password');
var exportedWalletJson = wallet.export();

Import wallet, decrypt it and get all claims of a specified DID or a claim by ID:

var wallet = new seraphId.SeraphIDWallet(exportedWalletJson);
wallet.decryptAll('password');

var allClaims = wallet.getAllClaims('did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs');
var claim = wallet.getClaim('claimId');

Seraph ID Issuer

Create issuer instance:

var issuer = new seraphId.SeraphIDIssuer('issuerSmartContractScriptHash', 'http://localhost:10332', 'http://localhost:4000/api/main_net', DIDNetwork.PrivateNet);

Create a new (revokable) credentials schema:

issuer.registerNewSchema('schemaName', ['firstName', 'lastName', 'age'], true);

Create and issue a claim:

var claim = issuer.createClaim('claimId', 'schemaName', {'firstName': 'John', 'lastName': 'Doe', 'age': 26}, 'did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs');

issuer.issueClaim(claim, 'issuerPrivateKey');

Revoke previously issued claim (if schema allows revocation):

issuer.revokeClaimById('claimId');

Seraph ID Verifier

Create verifier instance:

var verifier = new seraphId.SeraphIDVerifier('issuerSmartContractScriptHash', 'http://localhost:10332', 'http://localhost:4000/api/main_net', DIDNetwork.PrivateNet);

Get meta-data of issuer's credentials schema:

var schema = verifier.getSchemaDetails('schemaName');

Verify the given owner's claim offline (having issuer's public key):

var verfied = verifier.verifyOffline(claim, 'issuerPublicKey');

Verify the given owner's claim online (calling issuer's smart contract):

var verfied = verifier.verify(claim);

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.validateClaim(claim, function customClaimValidator(clm) {
    return clm.attributes.age > 18;
});

Check if issuer of owner's claim is trusted by the given Root of Trust:

var trusted = verifier.isIssuerTrusted('scriptHashOfRoTSmartContract', claim.issuerDID, claim.schema);

Seraph ID Root of Trust

Create Root of Trust instance:

var rot = new seraphId.SeraphIDRootOfTrust('rotSmartContractScriptHash', 'http://localhost:10332', 'http://localhost:4000/api/main_net', DIDNetwork.PrivateNet);

Register issuer's DID and schema as trusted:

rot.registerIssuer('did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs', 'SchemaName', 'rootOfTrustPrivateKey');

Remove trust for issuer's DID and schema from RoT:

rot.deactivateIssuer('did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs', 'SchemaName', 'rootOfTrustPrivateKey');

Check if issuer is trusted with the given schema:

var trusted = rot.isTrusted('did:neoid:priv:AKkkumHbBipZ46UMZJoFynJMXzSRnBvKcs', 'SchemaName');

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.git
cd seraph-id-sdk
yarn
yarn 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.