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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bsv/btms-permission-module

v1.0.1

Published

BTMS Permission Module for wallet integration

Readme

BTMS Permission Module

Wallet permission module for BTMS token spending authorization.

Overview

This is the core permission module for BTMS token operations - framework agnostic with no UI dependencies.

  • BasicTokenModule - Permission module that intercepts token operations and prompts users
  • Framework Agnostic - Works with any UI framework (React, Vue, Angular, vanilla JS)
  • Minimal Dependencies - Only requires @bsv/sdk and @bsv/wallet-toolbox-client

For ready-to-use React/MUI UI components, see @bsv/btms-permission-module-ui

Target Audience

This module is for wallet developers integrating BTMS token support into BRC-100 wallets via BRC-98/99 hooks.

Related Docs

Features

  • Token Spend Authorization: Prompts users before spending or burning BTMS tokens
  • Burn Authorization: Prompts users before permanently destroying tokens
  • Session-based Authorization: Caches authorization for transaction flows
  • Security Verification: Validates signature requests match authorized transactions
  • Rich Token Display: Shows amounts, names, metadata, and transaction details
  • Window Focus Management: Brings app to foreground when prompting (desktop apps)
  • Customizable UI: Use provided components or implement your own

Installation

npm install @bsv/btms-permission-module

Peer Dependencies

npm install @bsv/sdk @bsv/wallet-toolbox-client

Quick Start

1. Implement Your Prompt Function

import { BasicTokenModule } from '@bsv/btms-permission-module'

// Create a function that shows a prompt to the user
const requestTokenAccess = async (app: string, message: string): Promise<boolean> => {
  // Parse the token spend information
  const spendInfo = JSON.parse(message)
  
  // Show your UI (React, Vue, Angular, vanilla JS, etc.)
  const approved = await showMyCustomDialog({
    app,
    tokenName: spendInfo.tokenName,
    amount: spendInfo.sendAmount,
    assetId: spendInfo.assetId
  })
  
  return approved // true = user approved, false = user denied
}

2. Initialize the Module

const basicTokenModule = new BasicTokenModule(requestTokenAccess)

3. Register with Wallet

const permissionsManager = new WalletPermissionsManager(wallet, originator, {
  ...config,
  permissionModules: {
    btms: basicTokenModule
  }
})

Using with React/MUI

For a complete React implementation with Material-UI, install the UI package:

npm install @bsv/btms-permission-module-ui

Then use the provided hook:

import { BasicTokenModule } from '@bsv/btms-permission-module'
import { useTokenSpendPrompt } from '@bsv/btms-permission-module-ui'

const { promptUser, PromptComponent } = useTokenSpendPrompt()
const basicTokenModule = new BasicTokenModule(promptUser)

// Render the component
return (
  <>
    {children}
    <PromptComponent />
  </>
)

See the @bsv/btms-permission-module-ui package for full documentation.

Documentation

API Overview

BasicTokenModule

Permission module for BTMS token operations.

Constructor:

new BasicTokenModule(
  requestTokenAccess: (app: string, message: string) => Promise<boolean>
)

Message Format

The prompt message is a JSON string containing:

{
  type: 'btms_spend' | 'btms_burn',
  sendAmount: number,        // Amount being sent (0 for burn)
  burnAmount?: number,       // Amount being burned (for burn operations)
  tokenName: string,         // Token name
  assetId: string,          // Asset ID (txid.vout)
  recipient?: string,       // Recipient public key (not present for burn)
  iconURL?: string,         // Token icon URL
  changeAmount: number,     // Change returned
  totalInputAmount: number  // Total from inputs
}

Architecture

User Action → BTMS Core → BasicTokenModule → promptUser → UI → User Decision → Allow/Deny

See INTEGRATION.md for detailed flow diagrams.

Security

The module implements multiple security layers:

  • Session Authorization: Temporary auth for transaction flows
  • Preimage Verification: Validates signature requests match authorized transactions
  • Output Hash Validation: Ensures outputs haven't been modified

License

Open BSV