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

@trackback/vc

v0.0.1-alpha.24

Published

Verifiable Credentials js sdk

Downloads

26

Readme

ExpTrackback Logo

TrackBack VC SDK TrackBack VC SDK Build Node Version Lerna

TrackBack SDK for Verifiable Credentials & Presentations

This sdk handles for issuing and verifying verifying Credentials and Presentations that adhere to W3C standards.

IMPORTANT!

  • This is a minimum viable product suite with limited functionality.
  • Please do not use this for production
  • This is a part of SDKs for Verifiable Credentials, Verifiable Credential Presentations, DID Keys, Self Sovereign Identity and Decentralised Identifiers

Installation

yarn install

TrackBack Verifiabe Credentials

Architecture

Usage

Importing Verifiable Credentials

ES Modules import


import { VC } from '@trackback/vc'

CommonJS import


const { VC } = require('@trackback/vc');

Validate Verifiable Credentials


const vc = new VC();

const result = vc.validate({
                '@context': ['https://www.w3.org/2018/credentials/v1'],
                "type": ["VerifiableCredential"],
                "credentialSubject": {},
                "issuer": "did:trackback:issuer/1234"
            });

// true

Verifiable Credentials create JWT

import { JsonWebKey2020 } from '@trackback/key';
import { VC } from '@trackback/vc'

 
const vc = new VC();
const keyPair = await JsonWebKey2020.generate();

const credential = {
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    "type": ["VerifiableCredential"],
    "issuanceDate": "2010-01-01T19:23:24Z",
    "credentialSubject": {},
    "issuer": "did:trackback:issuer/1234"
}
const jwt = await vc.issueJWT({ keyPair, credential })

Verifiable Credentials validate JWT

import { JsonWebKey2020 } from '@trackback/key';
import { VC } from '@trackback/vc'

 
const vc = new VC();
const keyPair = await JsonWebKey2020.generate();

const credential = {
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    "type": ["VerifiableCredential"],
    "issuanceDate": "2010-01-01T19:23:24Z",
    "credentialSubject": {},
    "issuer": "did:trackback:issuer/1234"
}
const jwt = await vc.issueJWT({ keyPair, credential })

const result = await vc.verifyJWT(jwt, { keyPair, credential })

// true

Presentation

importing Verifiable Presentation


import { VP } from '@trackback/vc'

Verifiable Presentation create jwt

import { JsonWebKey2020 } from '@trackback/key';
import { VP } from '@trackback/vc'

const vp = new VP();

const keyPair = await JsonWebKey2020.generate();

const presentation = {
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    "type": ["VerifiablePresentation"],
    verifiableCredential: [{
        '@context': ['https://www.w3.org/2018/credentials/v1'],
        "type": ["VerifiableCredential"],
        "credentialSubject": {},
        "issuer": "did:trackback:issuer/1234"


    }]
}

const jwt = await vp.issueJWT({ keyPair, presentation })


// jwt

Verifiable Presentation validate jwt

import { JsonWebKey2020 } from '@trackback/key';
import { VP } from '@trackback/vc'

const vp = new VP();

// example json web key
const key = {
    id: 'did:trackback:key:SBQyXxAUa41yrBP9YJ-mPsCtESFjmzbOIUrzGI3-oWs#SBQyXxAUa41yrBP9YJ-mPsCtESFjmzbOIUrzGI3-oWs',
    type: 'JsonWebKey2020',
    controller: 'did:trackback:key:SBQyXxAUa41yrBP9YJ-mPsCtESFjmzbOIUrzGI3-oWs',
    publicKeyJwk: {
        crv: 'Ed25519',
        x: 'VBB9DDDSl3IMPNGlx5f4h-NY2AVKpOMauKqVSm3LYcU',
        kty: 'OKP',
        alg: 'EdDSA'
    },
    privateKeyJwk: {
        crv: 'Ed25519',
        d: 'nVlVbr0cfTf0KxIfha2LsOt3x4G7rJ2mRc_TbYXsscY',
        x: 'VBB9DDDSl3IMPNGlx5f4h-NY2AVKpOMauKqVSm3LYcU',
        kty: 'OKP',
        alg: 'EdDSA'
    }
}

// import key
const keyPair = JsonWebKey2020.from(key);

const JWT = `eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImtpZCI6ImRpZDp0cmFja2JhY2s6a2V5OlNCUXlYeEFVYTQxeXJCUDlZSi1tUHNDdEVTRmptemJPSVVyekdJMy1vV3MjU0JReVh4QVVhNDF5ckJQOVlKLW1Qc0N0RVNGam16Yk9JVXJ6R0kzLW9XcyJ9.eyJuYmYiOjE2MzQ2ODA2MDksInZwIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIl0sInR5cGUiOlsiVmVyaWZpYWJsZVByZXNlbnRhdGlvbiJdLCJ2ZXJpZmlhYmxlQ3JlZGVudGlhbCI6W3siQGNvbnRleHQiOlsiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiXSwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6e30sImlzc3VlciI6ImRpZDp0cmFja2JhY2s6aXNzdWVyLzEyMzQifV19fQ.mZLZIH-BOd3r72ryGEkfs7UBfIQ5_fSRchUo9h7DgIwd9L2BE3fhIviJW2X9YMIyEVeAi8C2Yz1m8ETT9pmHBw`

const presentation = {
    '@context': ['https://www.w3.org/2018/credentials/v1'],
    "type": ["VerifiablePresentation"],
    verifiableCredential: [{
        '@context': ['https://www.w3.org/2018/credentials/v1'],
        "type": ["VerifiableCredential"],
        "credentialSubject": {},
        "issuer": "did:trackback:issuer/1234"
    }]
}

const result = await vp.verifyJWT(JWT, { keyPair, presentation })

// true