diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5e972c7..10eab45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -124,6 +124,6 @@ hardware through WebHID or BitBoxBridge: make sandbox-dev ``` -The sandbox aliases `bitbox-api-ts` to `../src/index.ts`, so source edits +The sandbox aliases `@bitboxswiss/bitbox-api` to `../src/index.ts`, so source edits hot-reload without building `dist/`. Browsers cannot connect to the raw TCP simulator transport directly; simulator coverage belongs in `npm run test:sim`. diff --git a/README.md b/README.md index 6de676d..e78bcba 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# bitbox-api-ts +# @bitboxswiss/bitbox-api Pure TypeScript library for integrating BitBox02 hardware wallets in browser applications. -`bitbox-api-ts` is source-compatible with the current `bitbox-api` +`@bitboxswiss/bitbox-api` is source-compatible with the current `bitbox-api` Rust/WASM package for the implemented surface, but it does not ship WASM and does not require a WASM init step. @@ -20,7 +20,7 @@ does not require a WASM init step. ## Installation ```bash -npm install bitbox-api-ts +npm install @bitboxswiss/bitbox-api ``` `@noble/ciphers`, `@noble/curves`, and `@noble/hashes` are peer dependencies so @@ -43,7 +43,7 @@ For currently implemented methods, the intended migration is just the import name: ```ts -import * as bitbox from 'bitbox-api-ts'; +import * as bitbox from '@bitboxswiss/bitbox-api'; ``` There is no `init()` call and no WASM loader. Existing Webpack/Vite WASM plugin @@ -68,7 +68,7 @@ compatibility, but currently reject with typed errors as listed in ## Connecting and Pairing ```ts -import * as bitbox from 'bitbox-api-ts'; +import * as bitbox from '@bitboxswiss/bitbox-api'; async function connectBitBox(): Promise { try { @@ -131,8 +131,10 @@ const address = await bb02.ethAddress(chainId, keypath, true); ``` Transaction byte fields are big-endian `Uint8Array`s without a `0x` prefix. -Pass `ethIdentifyCase()` for the optional recipient case hint when you derive -the transaction from a hex address string. +Returned signature byte fields are plain `number[]` arrays, matching the +runtime shape of the old WASM package. Pass `ethIdentifyCase()` for the +optional recipient case hint when you derive the transaction from a hex address +string. ```ts function hexToBytes(hex: string): Uint8Array { diff --git a/package-lock.json b/package-lock.json index 35d24c7..9c21cc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "bitbox-api-ts", + "name": "@bitboxswiss/bitbox-api", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "bitbox-api-ts", + "name": "@bitboxswiss/bitbox-api", "version": "0.1.0", "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index e2120df..d2061bf 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "bitbox-api-ts", + "name": "@bitboxswiss/bitbox-api", "version": "0.1.0", "description": "A pure TypeScript library to interact with BitBox hardware wallets.", "license": "Apache-2.0", diff --git a/sandbox/index.html b/sandbox/index.html index 3018ac8..1a3caf0 100644 --- a/sandbox/index.html +++ b/sandbox/index.html @@ -3,7 +3,7 @@ - BitBox02 sandbox (bitbox-api-ts) + BitBox02 sandbox (@bitboxswiss/bitbox-api)
diff --git a/sandbox/src/App.tsx b/sandbox/src/App.tsx index d024f71..2cfceda 100644 --- a/sandbox/src/App.tsx +++ b/sandbox/src/App.tsx @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 import { useState } from 'react'; -import * as bitbox from 'bitbox-api-ts'; +import * as bitbox from '@bitboxswiss/bitbox-api'; import './App.css'; import { Ethereum } from './Ethereum'; @@ -86,7 +86,7 @@ function App() { - + {bb02.ethSupported() && ( @@ -124,7 +124,7 @@ function App() { )}

This sandbox is backed by the in-tree{' '} - bitbox-api-ts{' '} + @bitboxswiss/bitbox-api{' '} package. It validates the current browser integration and currently wired flows; it is not intended to track full API parity.

diff --git a/sandbox/src/Ethereum.tsx b/sandbox/src/Ethereum.tsx index d77a7f5..6a51417 100644 --- a/sandbox/src/Ethereum.tsx +++ b/sandbox/src/Ethereum.tsx @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 import { FormEvent, useState } from 'react'; -import * as bitbox from 'bitbox-api-ts'; +import * as bitbox from '@bitboxswiss/bitbox-api'; import { ErrorNotification } from './ErrorNotification'; @@ -39,6 +39,10 @@ function ResultBlock({ value }: { value: string }) { ); } +function formatResult(value: unknown | undefined): string { + return value === undefined ? '' : JSON.stringify(value, null, 2); +} + function EthXPub({ bb02 }: Props) { const keypaths = ["m/44'/60'/0'/0", "m/44'/1'/0'/0"]; const [keypath, setKeypath] = useState(keypaths[0]); @@ -199,7 +203,7 @@ function EthSignTransaction({ bb02 }: Props) {