0.0.1 • Published 3 years ago

pbt-js-alpha v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

TypeScript

About

This is a light-weight js lib that aims to make integration with Azuki PBT as seamless as possible. For more information on Azuki PBT please visit https://www.pbt.io/

Getting started

yarn add pbt-js

After installing you can import the relevant manufacturer's helpers

React example:

import { getPublicKeyFromScan, getSignatureFromScan } from 'pbt-js/kong';

const MyComponent = () => {
  const [keys, setKeys] = useState(null);

  return (
    <>
      <button
        onClick={() => {
          getPublicKeyFromScan({ rpId: '<host_of_current_site>' }).then((keys) => {
            setKeys(keys);
          });
        }}
      >
        Click Me To Initiate Scan
      </button>
      <button
        onClick={() => {
          getSignatureFromScan({
            rpId: '<host_of_current_site>',
            chipPublicKey: keys.primaryPublicKeyRaw,
            address: '<user_eth_address>',
            hash: '<blockhash>',
          }).then((sig) => {
            setSig(sig);
          });
        }}
      >
        Click Me To Sign EOA+blockhash w/ Chip
      </button>
    </>
  );
}

Documentation

This package exposes 2 functions for each chip manufacturer to support PBT flow

getPublicKeyFromScan

ParameterTypeDescriptionRequired
rpIdstringstring representing the domain the scan is being called on. For example a workflow hosted on azuki.com would pass in azuki.comyes

getSignatureFromScan

ParameterTypeDescriptionRequired
rpIdstringstring representing the domain the scan is being called on. For example a workflow hosted on azuki.com would pass in azuki.comyes
chipPublicKeystringyes
addressstringyes
hashstringyes

FAQ

Q: What manufacturers are currently supported?

A: There's currently only support for kongishcash chips

Contribution

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Fork the project Create your feature branch (git checkout -b feature/AmazingFeature) Commit your changes (git commit -m 'Add some AmazingFeature') Push to the branch (git push origin feature/AmazingFeature) Open a pull request

License

Distributed under the MIT License.