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

@babbage/tokenator

v0.2.37

Published

The ultimate tool for creating and transferring tokens

Downloads

156

Readme

tokenator

Overview

Tokenator is a versatile and powerful tool that allows developers to easily create and transfer tokens peer-to-peer on the MetaNet.

The base-level class provides basic functionality such as sending, receiving, and deleting messages, while derived classes can be used to build specialized tokens for various applications. Examples of these derived classes include PaymentTokenator, EmailTokenator, PushDropTokenator, and ScribeTokenator.

With Tokenator, developers can take advantage of the power of the BSV blockchain, the simple messageBox architecture of PeerServ, privacy and mutual authentication with Authrite, and monetization with PacketPay to create cutting-edge decentralized applications.

Installation

npm i @babbage/tokenator

Example Usage

const Tokenator = require('@babbage/tokenator')
const johnSmith = '022600d2ef37d123fdcac7d25d7a464ada7acd3fb65a0daf85412140ee20884311'

const init = async () => {
    // Create a new instance of the PushDropTokenator class
    // Configure the parameters according to the protocol being used
    const tokenator = new Tokenator({
        peerServHost: 'https://staging-peerserv.babbage.systems'
    })
    // Send a generic message using Babbage
    await tokenator.sendMessage({
        recipient: johnSmith,
        messageBox: 'example_inbox',
        body: 'This is an example message!'
    })

    // John can now list messages in his messageBox on PeerServ
    const messages = await tokenator.listMessages({
        messageBox: 'example_inbox'
    })

    console.log(messages[0].body) // --> 'This is an example message!'

    // Acknowledge that the messages have been received and can be deleted.
    await tokenator.acknowledgeMessage({
        messageIds: messages.map(x => x.messageId)
    })
}

init()

API

Table of Contents

PeerServMessage

Defines the structure of a PeerServ Message

Type: Object

Properties

  • messageId Number identifies a particular message
  • body String the body of the message (may be a stringified object)
  • sender String the identityKey of the sender
  • created_at String message creation timestamp as a string
  • updated_at String message update timestamp as a string

Tokenator

Extendable class for interacting with a PeerServ

Parameters

  • obj object? All parameters are given in an object (optional, default {})

    • obj.peerServHost String? The PeerServ host you want to connect to (optional, default 'https://staging-peerserv.babbage.systems')
    • obj.clientPrivateKey String? A private key to use for mutual authentication with Authrite. (Defaults to Babbage signing strategy)

initializeConnection

Establish an initial socket connection to a room The room ID is based on your identityKey and the messageBox

Parameters

listenForLiveMessages

Start listening on your "public" message room Anyone can send you a message here

Parameters
  • obj object all params given in an object

    • obj.onMessage function onMessage handler function
    • obj.messageBox string name of messageBox to listen on

sendLiveMessage

Send a message over sockets, with a backup of messageBox delivery

Parameters
  • obj object all params given in an object

    • obj.message string The message contents to send
    • obj.messageBox string The messageBox the message should be sent to depending on the protocol being used
    • obj.recipient string The identityKey of the intended recipient

sendMessage

Sends a message to a PeerServ recipient

Parameters
  • message object The object containing the message params

    • message.recipient string The identityKey of the intended recipient
    • message.messageBox string The messageBox the message should be sent to depending on the protocol being used
    • message.body (string | object) The body of the message

Returns String status message

listMessages

Lists messages from PeerServ

Parameters
  • obj Object An object containing the messageBox

    • obj.messageBox Array The name of the messageBox to list messages from

Returns Array<PeerServMessage> of matching messages returned from PeerServ

acknowledgeMessage

Acknowledges one or more messages as having been recieved ensuring deletion of the message(s)

Parameters
  • obj Object An object containing the messageIds

    • obj.messageIds Array An array of Numbers indicating which message(s) to acknowledge

Returns Array of messages formatted according to the particular protocol in use

License

The license for the code in this repository is the Open BSV License.