Coder Social home page Coder Social logo

did-provider-bbb's Introduction

Veramo plugin template

This template repository provides a bare-bones structure for writing an agent plugin for Veramo and/or for providing your own implementations for key management and storage, or for DID storage.

Quick start

  • Copy this repo
  • Rename package in package.json
  • yarn
  • yarn generate-plugin-schema to re-generate a schema for your plugin
  • yarn build or yarn watch
  • yarn start or VSCode Debugger (CMD + Shift + D) > Run OpenAPI server

Structure of this template

1. A custom Veramo agent plugin

An agent plugin for Veramo is a class that provides some methods to be called on the agent object, and also emit and listen to agent events triggered by other plugins.

This repository has an example of such a class in ./src/agent-plugin/my-plugin.ts that implements the myPluginFoo() method and listens to validatedMessage events and emits my-event and my-other-event.

The schema and data types associated with this plugin are declared in ./src/types/IMyAgentPlugin.ts

Adding a declaration for this in package.json is necessary to programmatically regenerate the schema for this plugin:

{
  //...
  "veramo": {
    "pluginInterfaces": {
      "IMyAgentPlugin": "./src/types/IMyAgentPlugin.ts"
    }
  }
}

A plugin can declare multiple interfaces, and each interface can have multiple methods and events. The schema for the plugin is (re)generated by running yarn generate-plugin-schema.

2. Custom key management templates

This template contains some skeleton code for some customizations to the ways keys are managed by Veramo. You can change how and where keys are stored and how they are encrypted by the default Veramo plugins, and/or create your own AbstractKeyManagementSystem implementation from scratch.

3. Custom DID management templates

You can change how DIDs are stored by Veramo. You can implement support for other DID methods by overriding MyIdentifierProvider

4. Use your plugin with @veramo/cli

See ./agent.yml for an example Veramo CLI configuration that uses the plugin and customizations from this template alongside other Veramo plugins to create a fully functioning agent.

Testing your plugin

There are a number of ways to test your plugin.

Integration tests

This repository contains 2 sample test setups that run the same tests in different contexts.

  • localAgent.test.ts creates an agent using agent.yml and runs the shared tests using that agent.
  • restAgent.test.ts creates an agent using agent.yml and runs it as a remote agent. Then, it creates another agent that uses @veramo/remote-client to expose the methods of the remote agent locally, and runs the tests using the local agent.

Call your agent using the Veramo OpenAPI server

You can also run yarn veramo server in your terminal and then go to http://localhost:3335/api-docs to see all the available plugin methods. You can call them after you click Authorize and provide the API key defined in agent.yml. By default, it is test123.

Step by step debugging

This repository includes some Visual Studio Code launch configurations that can be used for step by step debugging.

did-provider-bbb's People

Contributors

bozzzzo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.