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

@tbd54566975/tbdex

v0.8.0

Published

Library that includes type definitions for tbdex messages

Downloads

803

Readme

tbDEX Protocol

Library that can be used to:

  • create, parse, verify, and validate the tbDEX Messages and Resources defined in the protocol specification
  • send requests to PFIs

Table of Contents

Installation

npm install @tbd54566975/tbdex

Usage

Message Creation

There's a concrete class for each Message Kind. These classes can be used to create messages. e.g.

import { DevTools, Rfq } from '@tbd54566975/tbdex'

const rfq = Rfq.create({
  metadata : { from: alice.did, to: 'did:ex:pfi' },
  data     : {
    offeringId  : 'abcd123',
    payinMethod : {
      kind           : 'DEBIT_CARD',
      paymentDetails : {
        'cardNumber'     : '1234567890123456',
        'expiryDate'     : '12/22',
        'cardHolderName' : 'Ephraim Bartholomew Winthrop',
        'cvv'            : '123'
      }
    },
    payoutMethod: {
      kind           : 'BTC_ADDRESS',
      paymentDetails : {
        btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
      }
    },
    quoteAmountSubunits : '20000',
    vcs                 : ''
  }
})

await rfq.sign(alice)

console.log(JSON.stringify(rfq, null, 2))

Message Parsing

All messages can be parsed from json into an instance of the Message Kind's class using the Message.parse method. e.g.

import { Message } from '@tbd54566975/tbdex'

const jsonMessage = "<SERIALIZED_MESSAGE>"
const message = await Message.parse(jsonMessage)

if (message.isRfq()) {
  // rfq specific logic
}

Parsing a message includes format validation and integrity checking

Message Validation

[!NOTE]

TODO: Fill Out

Integrity Check

[!NOTE]

TODO: Fill Out

Sending Requests

[!NOTE]

TODO: Fill Out

Development

Prerequisites

node and npm

This project is using node v20.3.0 and npm v9.6.7. You can verify your node and npm installation via the terminal:

$ node --version
v20.3.0
$ npm --version
9.6.7

If you don't have node installed. Feel free to choose whichever approach you feel the most comfortable with. If you don't have a preferred installation method, i'd recommend using nvm (aka node version manager). nvm allows you to install and use different versions of node. It can be installed by running brew install nvm (assuming that you have homebrew)

Once you have installed nvm, install the desired node version with nvm install vX.Y.Z.

Running Tests

[!NOTE]

Make sure you have all the prerequisites

  1. clone the repo and cd into the project directory
  2. Install all project dependencies by running npm install
  3. start the test databases using ./scripts/start-databases (requires Docker)
  4. run tests using npm run test

npm scripts

| Script | Description | | ---------------------- | --------------------------------------------------------- | | npm run clean | deletes dist dir and compiled tests | | npm run test:node | runs tests in node runtime | | npm run test:browser | runs tests in headless browsers (chrome, safari, firefox) | | npm run lint | runs linter without auto-fixing | | npm run lint:fix | runs linter and applies automatic fixes wherever possible | | npm run build | builds all distributions and dumps them into dist |

Publishing Releases

[!NOTE]

This section is applicable to core maintainers only

[!IMPORTANT]

be sure to version bump the package in package.json before merging a PR

  1. After merging the PR, navigate to Github's tags section of this repo here Tags

  2. Click on Releases button and click Draft a new release.

  3. Click on Choose a tag, then create a new tag with the version number matching from step 3. The release title is also the same version number, i.e. v0.0.3 New release

  4. Click Generate release notes. This will auto-populate a list of all PRs merged to main since the last release. Generated release notes

  5. Click Publish release, which will kick off the Release to NPM Registry action, which you can see here

  6. After the github action is successfully completed, you will have a new version of @tbd54566975/tbdex available in the NPM registry.