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

vp-toolkit-models

v0.2.2

Published

Models for the w3c verifiable credentials standard

Downloads

31

Readme

vp-toolkit-models

Build Status Test Coverage Maintainability JavaScript Style Guide

A TypeScript/JavaScript library containing models for w3c verifiable credentials:

Installation

In an existing project (with package.json), install vp-toolkit-models

npm install vp-toolkit-models --save

Usage

We strongly advise the vp-toolkit library to generate and verify these models more easily. You can create the models by passing the required values through the constructor.

Example (VerifiableCredential)

The example below creates an unsigned VerifiableCredential object. To create a signed object, please use vp-toolkit.

import { VerifiableCredential, IVerifiableCredentialParams } from 'vp-toolkit-models'

const verifiableCredential = new VerifiableCredential({
  '@context': ['https://www.w3.org/2018/credentials/v1'], // Optional
  type: ['VerifiableCredential'],
  issuer: 'did:eth:0x6E29B1AE22195f9d59C1a468E292b78A8E6e15D1', // Issuer DID
  issuanceDate: new Date(),
  credentialSubject: {
    // The id is the DID as received from the holder / end-user, mandatory field
    id: 'did:eth:0x37F0d79f04b9C15dE4b31Bb70e828243644F5f49',
    givenName: 'John'
    // We advise to attest one property per credential to reduce correlation
  },
  credentialStatus: { // Optional
    // The ID/url/contract address of the credential (revoke) registry
    id: '0x6AbAAFB672f60C16C604A29426aDA1Af9d96d440',
    type: 'vcStatusRegistry2019' // The registry type
  },
  someOtherRandomField: 'anyValue', // Dynamic fields are accepted
  issuerName: 'YourOrganisation', // Optional
  issuerIcon: 'https://example.com/logo.png', // Optional
  proof: { // Required when sending to the counterparty
    type: 'SignatureAlgorithmName',
    created: new Date(), // UTC time will be used from this value
    verificationMethod: 'publicKey',
    nonce: '547d06de-7f1b-4040-8ad0-cbee414a4a7f',
    signatureValue: 'generated signature value'
  }
} as IVerifiableCredentialParams)

// Dynamic fields can be found in the additionalFields property
const someOtherRandomField = verifiableCredential.additionalFields['someOtherRandomField']

// Models can be stringified and parsed - the order of fields will not change.
const string = JSON.stringify(verifiableCredential)

The same approach works for a VerifiablePresentation and ChallengeRequest - but with different fields, obviously. The ChallengeRequest object supports Zero Knowledge Range Proof by offering the lowerBound and upperBound fields.

Extending models

If you don't prefer to use the dynamic fields, you can also extend the models in your own codebase. But when using the vp-toolkit, you might need to write or override a signer and generator in order to include your custom fields into the signature.

Running tests

Besides unit testing with Mocha, the effectivity of all tests are also measured with the Stryker mutation testing framework.

npm run test
npm run stryker

We aim to achieve a coverage of 100%. Stryker and/or mocha test scores below 80% will fail the build.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License and disclaimer

apache-2.0 with a notice.

We discourage the use of this work in production environments as it is in active development and not mature enough.