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

@coolwallets/sdk-core

v0.0.3

Published

Light core sdk of CoolWalletS

Downloads

5

Readme

SDK-Core

This package handles the apdu request for a CoolWalletS, also export a couple of classes to easily get started with CoolWalletS.

Use CWSDevice to register your current device, reset wallet or tune other settings.

Use CWSWallet to create or recover wallet in CoolWalletS.

Install

npm i @coolwallets/sdk-core

Quick Start

1. Keypair generation

For every APDU command, CoolWalletS will verify the identity of the requesting device (the App) by a digital signature, so we need to generate a key pair first for a new App.

import { generateKeyPair } from '@coolwallets/sdk-core'
const { publicKey: appPublicKey, privateKey: appPrivateKey } = generateKeyPair()

// store it locally on web storage
localStorage.setItem('appPublicKey', appPublicKey)
localStorage.setItem('appPrivateKey', appPrivateKey)

2. Device (App) Registration

After we have our keys ready, we need to register our device (app) so the wallet can recognize us.

This can be done by the CWSDevice instance. In the constructor, we need to put in a Transport object for bluetooth transport, and the appPrivateKey we just generated to sign all the commands. Here's a example how to use web-ble-transport with CWSDevice

const transport = new WebBleTransport();
const device =  new CWSDevice(transport, appPrivateKey)

You may notice that there's one more optional field called appId in the constructor, we don't have it yet so we will ignore it, and we will put the value in later with setAppId after we get our own appId from register.

device.register(appPublicKey, '123456', 'myFirstApp')
    .then( appId =>{
        localStorage.setItem("appId", appId)
        device.setAppId(appId)
        console.log(`Store AppId complete! ${appId}`)
    })

Congrats! Now your App can communicate with the hardware wallet, If you need to pair another App with the wallet, use a registered App to call device.getPairingPassword() and use it as the second parameter in register()

3. Wallet Creation

You can use createWallet to securely generate a new master seed with the card, or use setSeed to recover one from a hex seed.

import { CWSWallet } from '@coolwallets/sdk-core'
const wallet = new CWSWallet(transport, appPrivateKey, appId)

wallet.createWallet(12).then(_ => {
    // Sum all the seeds shown on CoolWalletS
    wallet.sendCheckSum(873209).then( _ => {
        console.log(`Successfully create a new wallet!`)
    })
})

4. Your turn

Build your own App with our sdk!