Skip to content

KNowledgeOnWebScale/vc-prototyping-library

Repository files navigation

vc-prototyping-library

The aim of this project is to collect here multiple verifiable credentials implementations.

It started by reusing the core code of vc-service.

To see how that was done, see FROM_VC_SERVICE_TO_HERE.md.

Prerequisites

  • Node v20 or higher

Setup

Installation

npm i

Build

Build to generate Typescript output in the ./dist directory:

npm run build

Bundle for browser usage

Bundle to generate one bundle for browser usage per implementation in the ./bundle directory:

npm run bundle

Usage

On the command line

Get help by executing:

node dist/cli.js

Some example commands (here for the solid implementation): run_cli_solid.sh

As a library in a node app

Please note that as long as this project is not published as a npm package, you may using methods such as npm link to refer to it from your project.

Proceed as follows:

  • Pick the implementation of your choice from: select it from the exports in package.json, for example: solid.

  • Import common definitions, an xxxApi and a xxxConfiguration, as in this example for the solid implementation:

    import { ContentType, Document, VerificationResult, IIssuer, IVerifier } from "vc-prototyping-library";
    import { SolidApi, SolidConfiguration } from "vc-prototyping-library/solid";
  • Construct an api object with the appropriate configuration and you're ready to go.

See the command line implementation and the test for implementations as a Typescript library for client code examples.

As a bundle in a browser app

Proceed as follows:

  • Pick the bundle for the implementation of your choice: copy one of the js files in directory bundle to your project. For example: copy bundle/solid/api.js to your project's vendors/vc/bundle/solid/api.js.

  • Import an xxxApi, as in this example for the solid implementation:

    import { SolidApi } from "./vendors/vc/bundle/solid/api.js";
  • Construct an api object with the appropriate configuration and you're ready to go.

See test for implementations as a Javascript browser bundle for a client code example.

Development

Watch

Build on any source file change by running this in a separate shell:

npm run watch

Add a new implementation

To add a new implementation, use src/implementations/solid) as an example. This is how to proceed, step by step:

  • Create a new directory, whose name is the name of your implementation in src/implementations/).

  • In this directory, create a file api.ts. It must start with the following import line:

    import { ContentType, Document, VerificationResult, IIssuer, IVerifier } from "../../api-spec.js";
  • In your api.ts, define a new configuration and api implementation, similar to SolidConfiguration and SolidApi in src/implementations/solid/api.ts).

  • Further implementation is up to you.

  • Do a global search in the project for "To support extra implementations" and follow the instructions you find there.

Preloading a JsonLdDocumentLoader

The BasicConfiguration in the src/api-spec.ts defines a property that can be reused in any configuration to define what JSON-LD documents to preload. See src/implementations/solid/api.ts for a first implementation that uses it.

Testing

Setup test infrastructure

For the Solid implementation, you need to set up a Solid pod. Execute:

npm run setup:css

Execute tests

We use Vitest. Execute:

npm run test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •