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/ledger

v0.0.2

Published

Universal Ledger Agent plugin for performing ledger actions on the Aries Cloudagent

Downloads

9

Readme

Universal Ledger Agent - Aries Cloudagent Ledger Plugin

npm (scoped)

This package handles everything that has to do with the ledger in Hyperledger Aries. It allows to perform operations to the ledger connected to the Aries Cloudagent.

Usage

LedgerController

import { EventHandler } from 'universal-ledger-agent'
import { LedgerController } from '@ula-aca/ledger'

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

const eventHandler = new EventHandler([ledgerController])

@ula-aca/ledger/register-nym

Send a NYM registration to the ledger.

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  LedgerController,
  RegisterNymMessage,
  RegisterNymResult,
  LedgerMessageTypes
} from '@ula-aca/ledger'

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

const eventHandler = new EventHandler([ledgerController])

const message: RegisterNymMessage = {
  type: LedgerMessageTypes.REGISER_NYM,
  body: {
    did: 'xZRz2JK8HngynkLe6m33J',
    verkey: 'XHLPXpGT9y5PaLo8n7pt379dXx6SLZYHqQN393yfA2e'
  }
}

eventHandler.processMsg(message, (response: UlaResponse) => {
  if (response.statusCode < 200 || response.statusCode >= 300) {
    // error
  } else {
    // response.body is response from /ledger/register-nym POST api endpoint in aca-py
    // https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/ledger/post_ledger_register_nym
    const result: RegisterNymResult = response.body
  }
})

@ula-aca/ledger/get-verkey-by-did

Get the verkey for a DID from the ledger.

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  LedgerController,
  GetVerkeyByDidMessage,
  GetVerkeyByDidResult,
  LedgerMessageTypes
} from '@ula-aca/ledger'

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

const eventHandler = new EventHandler([ledgerController])

const message: RegisterNymMessage = {
  type: LedgerMessageTypes.GET_VERKEY_BY_DID,
  body: {
    did: 'xZRz2JK8HngynkLe6m33J'
  }
}

eventHandler.processMsg(message, (response: UlaResponse) => {
  if (response.statusCode < 200 || response.statusCode >= 300) {
    // error
  } else {
    // response.body is response from /ledger/did-verkey api endpoint in aca-py
    // https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/ledger/get_ledger_did_verkey
    const result: GetVerkeyByDidResult = response.body
  }
})

@ula-aca/ledger/get-endpoint-by-did

Get the endpoint for a DID from the ledger.

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  LedgerController,
  GetEndpointByDidMessage,
  GetEndpointByDidResult,
  LedgerMessageTypes
} from '@ula-aca/ledger'

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

const eventHandler = new EventHandler([ledgerController])

const message: GetEndpointByDidMessage = {
  type: LedgerMessageTypes.GET_ENDPOINT_BY_DID,
  body: {
    did: 'xZRz2JK8HngynkLe6m33J'
  }
}

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

@ula-aca/ledger/get-transaction-author-agreement

Fetch the current transaction author agreement, if any

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  LedgerController,
  GetTransactionAuthorAgreementMessage,
  GetTransactionAuthorAgreementResult,
  LedgerMessageTypes
} from '@ula-aca/ledger'

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

const eventHandler = new EventHandler([ledgerController])

const message: GetTransactionAuthorAgreementMessage = {
  type: LedgerMessageTypes.GET_TRANSACTION_AUTHOR_AGREEMENT
}

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

@ula-aca/ledger/accept-transaction-author-agreement

Accept the transaction author agreement

import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
  LedgerController,
  AcceptTransactionAuthorAgreementMessage,
  AcceptTransactionAuthorAgreementResult,
  LedgerMessageTypes
} from '@ula-aca/ledger'

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

const eventHandler = new EventHandler([ledgerController])

// TODO: Add correct example for accepting TAA.
// Ledger needs to have a TAA, you can publish this with
// the ledger api from the indy sdk
const message: AcceptTransactionAuthorAgreementMessage = {
  type: LedgerMessageTypes.ACCEPT_TRANSACTION_AUTHOR_AGREEMENT,
  body: {
    mechanism: '',
    text: '',
    version: ''
  }
}

eventHandler.processMsg(message, (response: UlaResponse) => {
  if (response.statusCode < 200 || response.statusCode >= 300) {
    // error
  } else {
    // response.body is response from /ledger/taa/accept POST api endpoint in aca-py
    // https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/ledger/post_ledger_taa_accept
    const result: AcceptTransactionAuthorAgreementResult = response.body
  }
})

Examples

For example usage see the examples/ directory.