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

@ula-aca/credential-definition

v0.0.2

Published

Universal Ledger Agent plugin for creating and retrieving credential definitions from the ledger connected to Aries Cloudagent

Downloads

7

Readme

Universal Ledger Agent - Aries Cloudagent Credential Definition Plugin

npm (scoped)

This package handles everything that has to do with credential definitions in Hyperledger Aries. It allows to create and retrieve credential definitions from the ledger connected to the Aries Cloudagent.

Usage

CredentialDefinitionController

import { EventHandler } from 'universal-ledger-agent'
import { CredentialDefinitionController } from '@ula-aca/credential-definition'

const credentialDefinitionController = new CredentialDefinitionController({
  basePath: 'https://aca-py-api.com'
})

const eventHandler = new EventHandler([credentialDefinitionController])

@ula-aca/credential-definition/get-credential-definition-by-id

Gets a credential definition from the ledger

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  CredentialDefinitionController,
  GetCredentialDefinitionByIdMessage,
  CredentialDefinitionMessageTypes
} from '@ula-aca/credential-definition'

const credentialDefinitionController = new CredentialDefinitionController({
  basePath: 'https://aca-py-api.com'
})

const eventHandler = new EventHandler([credentialDefinitionController])

const message: GetCredentialDefinitionByIdMessage = {
  type: CredentialDefinitionMessageTypes.GET_CREDENTIAL_DEFINITION_BY_ID,
  body: {
    credential_definition_id: 'Bqqp9wananY4uW2pRHACiT:3:CL:10:my-cred-def'
  }
}

eventHandler.processMsg(message, (response: UlaResponse) => {
  if (response.statusCode < 200 || response.statusCode >= 300) {
    // error
  } else {
    // response.body is response from /credential-definitions/{id} api endpoint in aca-py
    // https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/credential-definition/get_credential_definitions__id_
    const result: GetCredentialDefinitionByIdResult = response.body
  }
})

@ula-aca/credential-definition/get-created-credential-definitions

Search for matching credential definitions that agent originated

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  CredentialDefinitionController,
  GetCreatedCredentialDefinitionsMessage,
  CredentialDefinitionMessageTypes
} from '@ula-aca/credential-definition'

const credentialDefinitionController = new CredentialDefinitionController({
  basePath: 'https://aca-py-api.com'
})

const eventHandler = new EventHandler([credentialDefinitionController])

const message: GetCreatedCredentialDefinitionsMessage = {
  type: CredentialDefinitionMessageTypes.GET_CREATED_CREDENTIAL_DEFINITIONS,
  body: {
    // schema_id: '',
    // schema_issuer_did: '',
    // schema_name: '',
    // schema_version: '',
    // issuer_did: '',
    // credential_definition_id: ''
  }
}

eventHandler.processMsg(message, (response: UlaResponse) => {
  if (response.statusCode < 200 || response.statusCode >= 300) {
    // error
  } else {
    // response.body is response from /credential-definitions/created api endpoint in aca-py
    // https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/credential-definition/get_credential_definitions_created
    const result: GetCreatedCredentialDefinitionsResult = response.body
  }
})

@ula-aca/credential-definition/create-credential-definition

Sends a credential definition to the ledger

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  CredentialDefinitionController,
  CreateCredentialDefinitionMessage,
  CredentialDefinitionMessageTypes
} from '@ula-aca/credential-definition'

const credentialDefinitionController = new CredentialDefinitionController({
  basePath: 'https://aca-py-api.com'
})

const eventHandler = new EventHandler([credentialDefinitionController])

const message: CreateCredentialDefinitionMessage = {
  type: CredentialDefinitionMessageTypes.CREATE_CREDENTIAL_DEFINITION,
  body: {
    tag: 'my-cred-def',
    schema_id: 'Bqqp9wananY4uW2pRHACiT:2:Test:1.0'
  }
}

eventHandler.processMsg(message, (response: UlaResponse) => {
  if (response.statusCode < 200 || response.statusCode >= 300) {
    // error
  } else {
    // response.body is response from /credential-definitions post request api endpoint in aca-py
    // https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/credential-definition/post_credential_definitions
    const result: CreateCredentialDefinitionResult = response.body
  }
})

Examples

For example usage see the examples/ directory.