Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitbox-api

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitbox-api

A library to interact with the BitBox02 hardware wallet

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
130
increased by4%
Maintainers
0
Weekly downloads
 
Created
Source

BitBox02 TypeScript/WASM library

A library to interact with the BitBox02 hardware wallet.

Check out the sandbox project that shows how to use this library.

Example:

import * as bitbox from 'bitbox-api';

// Run this in e.g. a button onClick event handler.
async function example() {
  try {
    const onClose = () => {
      // Handle disconnect.
    };
    const unpaired = await bitbox.bitbox02ConnectAuto(onClose);
    const pairing = await unpaired.unlockAndPair();
    const pairingCode = pairing.getPairingCode();
    if (pairingCode !== undefined) {
      // Display pairingCode to user
    }
    const bb02 = await pairing.waitConfirm();
    console.log('Product', bb02.product());
    console.log('Supports Ethereum functionality (Multi edition)?', bb02.ethSupported());
    const deviceInfos = await bb02.deviceInfo();
    console.log('Device infos:', deviceInfos);
  } catch (err) {
    const typedErr = bitbox.ensureError(err);
    console.log(typedErr);
  }
}

The package's bitbox_api.d.ts file contain a documentation of all types and functions.

WebPack

In WebPack projects, enable the asyncWebAssembly and topLeveLAwait features in your webpack.config.js (see https://webpack.js.org/configuration/experiments/):

module.exports = {
  //...
  experiments: {
    asyncWebAssembly: true,
    topLevelAwait: true,
  },
};

Vite:

Here is a sample vite.config.ts:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), wasm(), topLevelAwait()],
})

You need to install the wasm and topLevelAwait plugins to add them to the project.

Keywords

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc